0

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 ?

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.