So I’m creating a site to my client, and I’m designing the sub menus. My problem is that the sub menu links only contain title and href, and this isn’t working for me.
JS
<script>
$(document).ready(function(){
$('a').removeClass("valittu");
$('a [title="Taaperokurssi"]).addClass("valittu");
});
</script>
HTML
<a title="Taaperokurssi" href="xxx">Taaperokurssi</a>
<a title="Junnukurssi" href="xxx">Junnukurssi</a>
<a title="Yhteiseloa myötäkarvaan" href="xxx">Yhteiseloa myötäkarvaan</a>
<a title="Lapsi ja koira" href="xxx">Lapsi ja koira</a>
<a title="Pentutoko" href="http://hurttiajahuumoria.fi/kurssit/sujuva-arki/pentutoko">Pentutoko</a>
<a title="Aktivoi tokolla" href="xxx">Aktivoi tokolla</a>
<a title="Rallytoko" href="xxx">Rallytoko</a>
And a fiddle.
I thought that I could use CSS selectors with jQuery?
I have jQuery included, that shouldn’t be it.
Remove the space between
aand[. Having the space means to select the descendants of a tag with title attribute isTaaperokurssi.