How to call a hyperlink to activate or activate using jQuery Selector?

I have two tables, one of which is the master, and the other is a child table for the database. Each row of the sixth column in the main table has a link that updates the details table with the data for this row. The current line is highlighted. I have a button in the details table that scans each TR of the main table for a specific value in the first TD that contains the row number, and if the value is equal to the current row number + 1, the following code is executed:

$("tr").each(function() { var nextRownum = $(this).find("td[headers='COL01']").text(); if (parseInt(nextRownum) == parseInt(currentRownum) + 1) { $(this).find("td[headers='COL06']").find('a').click(); } }); 

$ (this) is TR. I know this works somewhat because I have the following code executed when the page loads ...

 $("td[headers='COL06']").find('a').each(function(){ $(this).click(function(){HighLight(this);}); }); 

... and when I click the button, the next line is highlighted, but the page does not refresh; that is, the hyperlink in my sixth column is not activated.

Any suggestions? Thanks; Matthew Moses

+4
source share
1 answer

By default, no .click is .click . You can do it

 window.location.href=$(this).find("td[headers='COL06'] a").attr('href'); // NB you won't ever need to .find().find() ^ 

or you can give the selected anchors a click event so that you can fire them

 <a href="http://www.google.com/" target="_blank" class="icanhasclick">Woo</a> $('a.icanhasclick').on('click', function(){ window.location.href=this.href; }); $(this).find("td[headers='COL06'] a").click(); 
+1
source

All Articles