javascript - Width Toggle Animate in jQuery doesn't work in FireFox? -


this question has answer here:

could doing wrong, or jquery animate function not work in firefox? works me in ie8, opera, , chrome, not firefox.

http://jsfiddle.net/neowot/kdlwg422/

if haven't messed syntax... workaround working in firefox too?

thank you.

html

<body>     <div id="searchicon">ar!</div> <div id="leftpanel"></div>  </body> 

css

body{     background:orange; }  #searchicon{     background:yellow;     height:20px;     width:40px; } #leftpanel{     position:absolute;     vertical-align:top;      background:green;     width:1096px;     height:588px; } 

js

$('#searchicon').click(function() {          event.preventdefault();         var togglewidth = $("#leftpanel").width() == 365 ? "1096px" : "365px";          $('#leftpanel').animate( {'width': togglewidth}, 300);    });    

remove event.preventdefault().

edit:

event isn't available in global scope in firefox. calling before defining it, creating error, preventing execution of rest of method. add event variable callback.

$('#searchicon').click(function(event) {      event.preventdefault();     var togglewidth = $("#leftpanel").width() == 365 ? "1096px" : "365px";      $('#leftpanel').animate( {'width': togglewidth}, 300);   });    

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -