I have some HTML and jQuery that slides a div
up and down to show or hide` it when a link is clicked:(我有一些HTML和jQuery,可在单击链接时上下滑动div
以显示或隐藏它:)
<ul class="product-info">
<li>
<a href="#">YOU CLICK THIS TO SHOW/HIDE</a>
<div class="toggle">
<p>CONTENT TO SHOW/HIDE</p>
</div>
</li>
</ul>
$('div.toggle').hide();
$('ul.product-info li a').click(function(event){
$(this).next('div').slideToggle(200);
}
My question is: How do I use preventDefault()
to stop the link acting as a link and adding "#" to the end of my URL & jumping to the top of the page?(我的问题是:如何使用preventDefault()
停止链接充当链接,并在URL末尾添加“#”并跳至页面顶部?)
I can't figure out the right syntax, I just keep getting an error saying(我找不到正确的语法,只是不断出现错误)
preventDefault() is not a function.(preventDefault()不是函数。)
ask by Chris J Allen translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…