javascript - toggleClass in jquery dosent work when i use id selector in Css -
i'm new @ jquery , have problem when use id selector in css jquery code doesn't work.
here html:
<body> <div id="fm"> </div> </body>
here javascript code:
$(function () { $("#fm").click(function () { $(this).toggleclass("cm"); }); });
this css ok , works:
body>div{ height:100px; background-color:blue; transition:all ease 0.5s; position:fixed; top:0; left:0; bottom:100px; right:0; z-index:1000; }
but if use #fm
in css selector doesn't work. think may because of cascading behavior don't know how fix it.
here css doesn't work:
#fm{ height:100px; background-color:blue; transition:all ease 0.5s; position:fixed; top:0; left:0; bottom:100px; right:0; z-index:1000; border:1px solid black; }
and cm class
.cm { background-color:red; height:150px; }
i appreciate if help
try
#fm.cm
for cm rule. way, id doesn't override class
Comments
Post a Comment