Editable Row In A Table - Is Using The Record ID On A Element Bad Practice?
I'm trying to make a feature using jquery to edit a HTML table of category names. So far I have my table being populated using PHP/MySQL. This all works ok. I've read jQuery - Edit
Solution 1:
What you should be looking into is data attributes
.
How you use them is ..
<tr data-id="2">
<td>Foo</td>
....
</tr>
<tr data-id="3">
<td>Bar</td>
....
</td>
And lets say you need to get the id of a clicked row, you can do so by using .data()
method.
...
$('tr').on('click', function(){
id = $(this).data('id');
...
});
...
I'm trying to make a feature using jquery to edit a HTML table of category names. So far I have my table being populated using PHP/MySQL. This all works ok. I've read jQuery - Edit
Solution 1:
What you should be looking into is data attributes
.
How you use them is ..
<tr data-id="2">
<td>Foo</td>
....
</tr>
<tr data-id="3">
<td>Bar</td>
....
</td>
And lets say you need to get the id of a clicked row, you can do so by using .data()
method.
...
$('tr').on('click', function(){
id = $(this).data('id');
...
});
...
Post a Comment for "Editable Row In A Table - Is Using The Record ID On A Element Bad Practice?"