0

I have this code right now to get the row value from jquery grid..

$("#table1").click(function(e) {
                var row = jQuery(e.target).parent();
                value = row.attr("id");

I need to loop all the rows to get the values.

Can anyone help me out that? if I click on second row I need get second row value, if I click on first row I need to get first row value.

1 Answer 1

1

Try this:

$('tr', '#table1').live('click', function(){
    var id = $(this).attr('id');
});
Sign up to request clarification or add additional context in comments.

3 Comments

I would strongly recommend to use $('#table1').delegate('tr', 'click', function(){});
Why? I cannot find any difference. Both binds click to the #table1 element and checks event target from there on.
Actually, if you take a look at the jQuery 1.4.2 source code, on lines 2411-2413, the only thing that the delegate extension does is to call $.fn.live on the context.

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.