javascript - JQuery .animate() only works in Chrome -


i using jquery .animate() function slide divs in container div. works without issue in google chrome, when try in either firefox or ie, divs become garbled mess , don't slide. i'm new javascript , ignorant in ways of browser compatibility, can point me in right direction? here relevant code:

the html

<div id="slider">   <div id="main" class="content">   </div>    <div id="projects" class="content">   </div>    <div id="about" class="content">   </div>    <div id="contact" class="content">   </div> </div> 

the css

#slider {   width: 100px;   height: 100px;   overflow: hidden;   position: relative; }  #main {   background-color: red;   width: inherit;   height: inherit;   position: absolute; }  #projects {   background-color: blue;   width: inherit;   height: inherit;   position: absolute; }  #about {   background-color: yellow;   width: inherit;   height: inherit;   position: absolute; }  #contact {   background-color: green;   width: inherit;   height: inherit;   position: absolute; }  .content {   left: 0;   top: 0; } 

the javascript

$(document).ready(function() {  var contentwidth = '100px';  for( var i=0; < 2; i++) {   $('.gallery' + (i + 1)).colorbox({ opacity:0.5 , rel:'gallery' + (i+1)}); }  $('.content').css({   position: 'absolute',   left: contentwidth });  $('#main').addclass('visible'); document.getelementbyid('main').style.left = "0";  $("li a").click(function () {   event.preventdefault();   var $blockid = $( $(this).attr('href') );    if ($blockid.hasclass('visible')) { return; }    $('.content.visible')     .removeclass('visible')     .animate({ left: '-=100px' }, {         duration: 'slow',       complete: function () {         $(this).css('left', '100px');       }     }  );  $blockid   .addclass('visible')   .animate({ left: 0 }, {duration: 'slow'}); });  }); 

jsfiddle: http://jsfiddle.net/bwvvz/

i can provide link site in question, although hold off because not sure if against rules. appreciated!

you missing event argument click handler

$("li a").click(function(){      event.preventdefault();     //... }); 

it should

$("li a").click(function (event){     event.preventdefault();     //... }); 

demo.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -