How to read the class of an element?
Hi,
Sorry, Im very new to jQuery and trying to create a "click-and-hide" navigationbar.
This is what I have:
-
function ShowHide(){
$("#navigation_sub").animate({"width": "toggle"}, { duration: 500 });
}
Great, hm? When u click the link it calls "ShowHide" which works well. The div "#navigation_sub" is hiding and appearing when I click it. Now I want the main-content-area ("#content") to be 100% width if the navigation_sub is hidden.
I found "addClass" and "removeClass", but I want to addClass only if #content doesn't have the new one already. See my point?
Originally the #content div has "class=span-18 last". When I click "hide" it should have "class=content_wide". When I click again it should remove "content_wide" and add "span-18 last".
How can I do this?
I tried things like
-
var myClassAttr = $("#navigation_sub").attr("class");
if( $myClassAttr == "span-18 last" ) {
alert "hallo";
}
But it didnt work. Any hints?
Thanks a lot!!!