简体   繁体   中英

jQuery .slideDown executes twice instead of once

I'm new to jquery and bumped into a problem i can't fix

I want that on pageload my content is sliding down so i use the next code:

  $(document).ready(function () {
    $("#content").hide();
    $("#content").slideDown(1000);
  });

when i load the page the content slides down narmally, than the content gets hidden and slides down again.

When i go to the css and do #content{display: none;} instead of $("#content").hide(); everything works fine. (can't use this for browsers without js)

Does anyone know the cause of this?

Thanks!

You are saying that everything works fine while using css #content{display: none;} than i offer u to use Jquery.css() method( http://api.jquery.com/css/ )..

u can use it like:

  $(document).ready(function () {
    $("#content").css( { 'display' : 'none' } );
    $("#content").slideDown(1000);
  });

sipmle as that.

and i also agree with @Billy Moon, it can be a browser specific bug or u may be calling a page refresh command, somewhere within ur code.

Your code has no problem inside. It's somewhere else in your code.

isn't that function call in some function that is called twice?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM