Can anyone tell me why, even when my alert shows that my regular expression strings match, the if statement is not triggered? I have sample code below. Thanks in advance.
$(document).ready(function () {
$('div#primaryNavigation').find('a').each(function () {
var pattern = /my-link1|my-link2|my-link3|my-link4/;
var myWindow = window.location.pathname.match(pattern);
var href = $(this).attr('href').match(pattern);
alert('Show link and href until match: ' + myWindow + ' ' + href);
if (myWindow == href) {
//* Do Something *
};
});
});