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:

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

{{ parent.tldr }}

{{ parent.urlSource.name }}