hidden - How to set the jQuery slideUp() Method to hide elements when the page loads -


i using slideup , slidedown jquery function display images on webpage slide text down once clicked on. in following code have js set when load page text down. slide function works, have page load text hidden/up.

any suggestions how can alter code have text hidden when page loads highly appreciated. thank in advance taking time @ this!

here code:

jquery(document).ready(function($) {   $(".pic").click(function(e) {  var more = $(this).find('.more');  if ( $(more).is(':visible') ) {     $(more).slideup('fast') } else {     $(more).slidedown() } $('.more').not( $(more)).slideup() })   }); 

you have 2 options. either set initial .pic state hidden in css so:

.more {     display: none; } 

or trigger javascript event after setting callback, because they're presently visible, hide them. can done so:

jquery(document).ready(function($) {     $(".pic").click(function(e) {         var more = $(this).find('.more');          if ($(more).is(':visible')) {             $(more).slideup('fast')         } else {             $(more).slidedown()         }         $('.more').not($(more)).slideup()     }).trigger('click');  }); 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -