Quelqu'un peut-il me dire pourquoi, même lorsque mon alerte montre que mes chaînes d'expressions régulières correspondent, l'instruction if n'est pas déclenchée? J'ai l'exemple de code ci-dessous. Merci d'avance.Mon expression régulière ne correspond pas à l'instruction conditionnelle
$(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 *
};
});
});
qu'en est-il '/ my-link [1-4] /' – jAndy
@jAndy je crois que mylink1 etc sont des espaces réservés – Amarghosh