Reputation:
Losing my mind on this one..
How can I do something as simple as..
If div has class "something" then make div#test have a class of "awesome"
<div class="something">hey there</div>
<div id="test">Am I awesome?</div>
Much Thanks!
Upvotes: 1
Views: 137
Reputation: 3175
jQuery has a .hasClass() method that is useful, albeit maybe not exactly what you are looking for.
Upvotes: 0
Reputation: 19029
If you want to check the class of a particular div, then change your html
<div id="im_special" class="something">hey there</div>
and then look for the id in the javascript
if ($("div#im_special.something").length) {
$("div#test").addClass("awesome");
}
Upvotes: 0
Reputation: 655785
Try this:
if ($("div.something").length) {
$("div#test").addClass("awesome");
}
Upvotes: 2