I am trying to create a drop down menu list using jQuery and simple CSS at this Demo the sliding works fine but I don't know why on click function the page also refreshes (this is more obvious when you look at the
Here is the code I have:
<style>
.musthidden{display:none;}
</style>
<ul>
<li><a href="#">One</a></li>
<li id="two"><a href="#">Two</a>
<ul class="musthidden">
<li><a href="#">Two _ 1</a></li>
<li><a href="#">Two _ 2</a></li>
<li><a href="#">Two _ 3</a></li>
<li><a href="#">Two _ 4</a></li>
</ul>
</li>
<li><a href="#">Three</a></li>
<li><a href="#">Four</a></li>
</ul>
<script>
$("#two").on("click",function(){
$(".musthidden").slideToggle();
});
</script>
Can you please let me know why this is happening?
#twoli. It's reloading because of the inner<a>(anchor) tag. The reason, you're not seeing it is because it's in an<iframe />.