Skip to content

Instantly share code, notes, and snippets.

@kayhadrin
Created November 12, 2014 23:22
Show Gist options
  • Save kayhadrin/e05bdb3e0c8fae5524a7 to your computer and use it in GitHub Desktop.
Save kayhadrin/e05bdb3e0c8fae5524a7 to your computer and use it in GitHub Desktop.
A Pen by David.
<div>
<span>
<a class="menu-item">Home</a>
</span>
<span>
<a class="menu-item">Contact</a>
</span>
</div>
$(function(){ // make sure that you run the code when the page DOM elements are ready
$('div > span .menu-item:contains("Home")').css('font-weight', 'bold');
// Optimisation: Instead of using "div" as the start, we should use something more specific like #id or .cssClassName to avoid going over every DIV of the page
});
/* this is just to make the test page look a bit nicer */
body {
margin: 1em;
}
.menu-item {
border: 1px solid blue;
padding: .5em;
}
a {
text-decoration: underline;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment