I'm kind of new in JS and jQuery, and this is my first question here, I hope I make it clear:
I have a list of <a>, and I want to apply style only to the one whose href is the same than the URL.
I tried to simplify my html to show you, something like this:
<a href="/myWeb/001.html"></a>
<a href="/myWeb/002.html"></a>
<a href="/myWeb/003.html"></a>
<a href="/myWeb/004.html"></a>
Then, this is what I started on my Script (with jQuery):
var url = window.location.pathname;
if($('a').attr('href') === url){
//and now I want to apply .css() only to the <a> that passes the condition
}
So, is frustrating I can't achieve to attack the right object, and I guess is more than simple :/, any tip?
Thanks.
Aucun commentaire:
Enregistrer un commentaire