Reputation: 933
I want to add a column to my table. My js code is as follows:
jQuery(document).ready(function () {
jQuery('#addCol').click(function () {
var countRows = $('#blacklistgrid tr').length;
$('.class').each(function() {
$( this ).append("<td><input type=\"text\"/></td>");
});
});
This code can be found in the fiddle. What am I doing wrong ?
Upvotes: 0
Views: 187
Reputation: 12672
You're targeting the wrong element.
You should do this:
jQuery('.Row').each(function() {
jQuery( this ).append("<td><input type=\"text\"/></td>");
});
Notice jQuery('.Row')
instead of jQuery('.class')
See the docs, the class selector is used like jQuery('.<classname>')
, and in this case you want to get each rows, which are identified by Row
class
Upvotes: 2