I’m using jQuery tablesorter to add functionality to a couple of tables. I have the zebra effect and mouseover to highlight rows, and all is fine. On several rows, I have href links that are clickable, and they open the correct urls. However, and here is my problem, even the rows that have no href links are trying to open urls, and consequently throwing page errors.
This is my code for the links:
$(".tablesorter tr").click(function() {
window.location.href = $(this).find("a").attr("href");
});
I guess I have to check rows for ‘a’, and if not found, then do nothing. Sounds easy, but how do I code it?!
Any help would be greatly appreciated! As you probably guessed, I am new to jQuery and programming and have begun a very steep learning curve!!!
http://api.jquery.com/find
Originally, I thought I would use
contains[API ref], but this works differently than I thought. I changed my example above to usefindinstead.Alternatively, you could do: