I have the following code:
var left_blah = [];
var right_blah = [];
$('#left tr td:first-child').each(function(idx){
if(idx !== 0){
left_blah.push($(this));
}
});
$('#right ol li a').each(function(){
right_blah = ($(this));
});
$(left_blah).each(function(idx_left, left){
$(right_blah).each(function(idx_right, right){
if($(left).html() == $(right).attr("title").substr(12,11)){
console.log('found a match');
}
});
});
…which doesn’t seem to work. I’m basically just trying to compare the two arrays above and apply some CSS to some links in left_blah. What am I doing wrong?
left_blah contains some TD objects.
right_blah contains some hyperlink objects.
If the numeric I’m parsing for matches from both, then I’d like to apply CSS to the respective element in the right_blah array.
(The TDs contain a numeric I’m parsing for using < element >.html() and the hyperlinks contain this same numeric I’m looking for in my business logic but only in the title tag (which is okay because I can still grab it using attr(‘title’)…)
Anyway, that IF block isn’t outputting “found a match” in Firebug nor does it do anything else if I tell it to (i.e. - apply CSS, print anything, etc.) I can’t seem to understand why either because when I do something like console.log(left) or console.log(right) directly BEFORE the IF, everything outputs as expected.
Any ideas why? (Feel free to provide insights into more efficient ways to do this, too.)