html - How to hide content first in Toggle(hide/show) button with jquery -
i made toggle button jquery. opened page, first see content visible. when clicked on button hides. want make first hide , when click on button show.
first image before click second after click
html
<button id="pak">asia</button> <div class="asia"> <ul> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/aisa.html"> <font size="4">list of cities in asia</font></a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/shag.html"> shanghai</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/toky.html"> tokyo</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/kara.html"> karachi</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/dehl.html"> dehli</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/mumb.html"> mumbai</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/beij.html"> beijing</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/seou.html"> seoul</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/hong.html"> hong kong</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/gaun.html"> gaungzhou</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/uzbe.html"> uzbekestian</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/tehr.html"> tehran</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/laho.html"> lahore</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/riya.html"> riyadh</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/jedd.html"> jeddah</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/jakt.html"> jaktara</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/osak.html"> osaka</a></li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/tian.html"> tianjin</a></li> </ul> </div>
javascript
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> $(document).ready(function(){ $("#pak").click(function(){ $(".asia").toggle(700); }); }); </script>
can ?
add style display:none
element or class, hide element on page load
$(document).ready(function() { $("#pak").click(function() { $(".asia").toggle(700); }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <button id="pak">asia</button> <div class="asia" style="display:none"> <ul> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/aisa.html"> <font size="4">list of cities in asia</font></a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/shag.html"> shanghai</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/toky.html"> tokyo</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/kara.html"> karachi</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/dehl.html"> dehli</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/mumb.html"> mumbai</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/beij.html"> beijing</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/seou.html"> seoul</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/hong.html"> hong kong</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/gaun.html"> gaungzhou</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/uzbe.html"> uzbekestian</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/tehr.html"> tehran</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/laho.html"> lahore</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/riya.html"> riyadh</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/jedd.html"> jeddah</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/jakt.html"> jaktara</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/osak.html"> osaka</a> </li> <li><a href="file:///c:/documents%20and%20settings/maheer/desktop/cities/tian.html"> tianjin</a> </li> </ul> </div>
Comments
Post a Comment