I have the following code:
$(".perf-row").click(function(e) {
if (e.target.tagName.toLowerCase() == "a") {
pageTracker._trackPageview($(this).attr("rel"));
return true; //link clicked
} else {
window.open($(this).attr("rel"));return false;
}
});
to the conditional statment of if (e.target.tagName.toLowerCase() == "a") i would like to also add “OR class is equal to price”.
I’m not quite sure how to do that, i can’t seem to find the class of the clicked element (which will be a td inside the table row).
i’ve tried $(this).class, $(this.class) but neither work….
Help would be greatly appreciated!
You could combine both your tests into a single jQuery command:
That tests if the target is either has the class
price, or is anatag, or is both. If you wanted to test that it was anatag and had thepriceclass, you would use this:Update: I may have misread your question. If you were going to add this second test to the same
iftest, then use my code. If you wanted to add aelse ifthen use the.hasClassmethod as explained by the other answers.