Over a million developers have joined DZone.

Linked Table Jquery Plugin

·
This is a simple jquery plugin for adding a click handler to a table row. The click handler searches the descendants of the TR for an anchor with the class "row-link". When found the window.location is set to the value of the href attribute, sending the user to that page.

example: $("table-selector").linkRows();


$.fn.linkRows = function() {
  $(this).each(function() {
    $("a.row-link", "tr").each(function() {
      var $a = $(this);
      $(this).closest("tr")
        .click(function() {
        window.location = $a.attr("href");
      });
    });
  });
  return this;
};
Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}