Reputation: 18299
I have two tables, one being a master and one being a child table for a database. There is a link in every row on the 6th column in the master table that refreshes the detail table with data for that row. The current row is highlighted. I have a button on the detail table that searches through each TR of the master table for a particular value in the first TD which holds the row number, and if the value equals 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) being the TR. I know that this works somewhat, because I have the following code executing on page load...
$("td[headers='COL06']").find('a').each(function(){
$(this).click(function(){HighLight(this);});
});
...and when I click the button, the next row gets highlighted, but the page does not refresh; i.e., the hyperlink in my 6th column isn't being activated.
Any suggestions? Thank you; Matthew Moisen
Upvotes: 4
Views: 80
Reputation: 28419
There is no .click
by default on an anchor. You could do this
window.location.href=$(this).find("td[headers='COL06'] a").attr('href');
// NB you won't ever need to .find().find() ^
or you could give selected anchors a click event so that you can trigger 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();
Upvotes: 1