[英]slide down with toggle function
i want to toggle my div with anchor tag but code is not working. 我想用锚标记切换我的div,但是代码不起作用。 please let me know where i have mistake in code. 请让我知道我在代码中有错误的地方。
jquery code
$(document).ready(function () {
$('#status_1').click(function (e) {
e.preventDefault(); //to prevent default action of link tag
$(this).parent().next('.hide-show').slideToggle();
});
});
html code
<a href="#" id="status_1" class="bitcon"></a>
<div class="hide-show">
Hellow world
</div>
Css:
.hide-show{
display: none;
}
So, Why are you put parent in it?? 那么,为什么要放父母呢? This is sibling of anchor my friend 这是我朋友的主播
If you want to use parent then 如果你想使用父母
$(this).parent().find('.hide-show').slideToggle();
Your issue might be with part of the code here: " $(this).parent().next " 您的问题可能出在这里的部分代码:“ $(this).parent()。next”
you can try simply: 您可以尝试简单地:
$('.hide-show').slideToggle();
This will select your div with the class hide-show and apply .slidetoggle(); 这将使用class hide-show选择div并应用.slidetoggle();。 to it. 对此。
Instead of what you currently have which is looking for the parent of the link with class status_1 and finding the next link. 寻找当前状态为class_1的链接的父级并找到下一个链接,而不是当前的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.