jQuery addclass, removeclass and click event problems ( code ) -
jquery(document).ready(function () { jquery('.issocial').click(function () { var hidden = jquery('.socialhidden'); hidden.animate({ "top": "35px" }, 400); jquery(".socialhidden>div").delay(400).animate({ opacity: "1" }, 150); jquery(".issocial").addclass("closejs").removeclass("issocial"); homecoming false; }); jquery('.closejs').click(function () { var hidden = jquery('.socialhidden'); hidden.delay(200).animate({ "top": "-176px" }, 400); jquery(".socialhidden>div").animate({ opacity: "0" }, 150); jquery(".closejs").addclass("issocial").removeclass("closejs"); }); });
can help me prepare code? first part works perfectly... when seek sec 1 working, nothing.
this html:
<button class="issocial">button</button> <div class="socialhidden"> <div> content..... </div> </div>
since changing classes dynamically, should utilize event delegation binding events,
jquery(document).ready(function () { jquery(document).on("click", '.issocial', function () { var hidden = jquery('.socialhidden'); hidden.animate({ "top": "35px" }, 400); jquery(".socialhidden>div").delay(400).animate({ opacity: "1" }, 150); jquery(".issocial").addclass("closejs").removeclass("issocial"); homecoming false; }); jquery(document).on("click", '.closejs', function () { var hidden = jquery('.socialhidden'); hidden.delay(200).animate({ "top": "-176px" }, 400); jquery(".socialhidden>div").animate({ opacity: "0" }, 150); jquery(".closejs").addclass("issocial").removeclass("closejs"); }); });
jquery
No comments:
Post a Comment