Link to home
Create AccountLog in
Avatar of Simon Leung
Simon Leung

asked on

use JQuery to query HTML row

Is there any example on using JQuery to display each column of a selected row in a HTML table ?

Avatar of Brian Tao
Brian Tao
Flag of Taiwan, Province of China image

Yes, give the table an ID (e.g. "theTable") or use other selector, and the following code can do the trick:
  $("#theTable tr").click(function(e){
    var result = "";
    $.each($(this).children(), function(idx, obj){
      result += idx + ": " + $(obj).text() + "\n";

Open in new window

see attached example
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account