jQuery: specifiying the index of a child <td> in a row's onclick function -


i have click function table row needs pass content of first 2 tds in row.

// assign click handler rows $('#supporttables1 tr').click(function () {     var firsttd = $(this).find('td').html();     //need next td.  below line doesn't work.     var secondtd = $(this).find('td')[1].html();     window.open('snglcontactlist.php'+'?search_word='+firsttd+'?list_name=secondtd); }); 

i can first td fine, i'm stumped on i'm sure profoundly simple matter of accessing second td (i've tried diferrent methods of setting it's index).

the array notation [1] returns dom element, not jquery object, can't use .html() (a jquery method) on it. use jquery function .eq() elements instead:

  // assign click handler rows   $('#supporttables1 tr').click(function ()   {         var firsttd = $(this).find('td').eq(0).html();         var secondtd = $(this).find('td').eq(1).html();         window.open('snglcontactlist.php'+'?search_word='+firsttd+'?list_name='+secondtd);   }); 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -