我想用 anchor 标记切换我的 div,但代码不工作。请让我知道我的代码哪里有错误。
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;
}
最佳答案
那么,为什么要将 parent 放入其中? 这是主播我 friend 的 sibling
如果你想使用parent那么
$(this).parent().find('.hide-show').slideToggle();
关于javascript - 向下滑动切换功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27081751/