JS beginner here.
I need help with a script to place different content in a div depending on whether the page body tag has a class of “home” or not.
I am trying to use .hasClass & .html to achieve this. It seems like it should be extremely straightforward, but I can’t figure it out. Lack of proper syntax knowledge? Incorrect declarations? I don’t know, and am hoping someone can point me in the right direction!
if ($("body").hasClass("home") == true) {
("#mobilemenu").html("<a href="#">HOME</a>");
}
else {
("#mobilemenu").html("<a href="#">NOT HOME</a>");
}
the JSFiddle (which currently does nothing) is here:
http://jsfiddle.net/aqyN4/
Links to other JSFiddles or questions with similar functions extremely welcome!
Thank you,
Ali
you forgot
$before("#mobilemenu"):demo : http://jsfiddle.net/aqyN4/4/