I didn’t know if there was a post for this already because I don’t know exactly how to word the question, so I’ll give an example..
<ul class=filters>
<li class=segment-1>
<a href="#">Web</a>
</li>
</ul>
The code is for a list that filters a gallery when you click a list item.
I’m thinking I should be able use the code to select “Web” for example so that I can automatically filter the gallery upon the page loading.
$('element*="Web"').click();
Is this the best way to do things? And if it is.. what do I put in place of “element” to select Web
There are better ways, which won’t have to be updated everytime the text of your markup changes slightly.
Either add a class to the anchor tag, with some meaningful name related to its purpose, then do the following (I used
navLinkas the class name):Or use the existing markup hierarchy:
P.S. Note that I fixed the quotation marks around your attribute values in your markup: