0

I have problem with my code, I want change to by id

this is my PHP

<?php
    foreach($brands->result() as $row){
?>
    <tr id ="<?=$row->brand_id?>">
        <td><?=$row->brand_id;?></td>
        <td class="editableName"><?=$row->name_brand;?></td>
        <td class="editableDesc"><?=$row->description;?></td>
        <td>
            <button id="edit" class="form-control">Edit</button>
            <a href="<?=base_url('Admin/brands/delete')?>/<?=$row->brand_id;?>"><button class="form-control">Delete</button>
        </td>
    </tr>
<?php 
    } 
?>

This is my JQuery

$('#edit').click(function () {
    $(this).parents('tr').find('td.editableName').each(function() {
        var html = $(this).html();
        var input = $('<input name="name" class="form-control" type="text" />');
        input.val(html);
        $(this).html(input);
    });
    $(this).parents('tr').find('td.editableDesc').each(function() {
        var html = $(this).html();
        var input = $('<input name="description" class="form-control" type="text" />');
        input.val(html);
        $(this).html(input);
    });
});

i am using that jquery script its only work on 1st row, the nth row doesn't work

Ignacio Ara
  • 2,476
  • 2
  • 26
  • 37

0 Answers0