我的 jQuery on click 函数有问题。我无法弄清楚我做错了什么,因为它甚至没有在控制台中注册点击(我已经设置了断点并且它拒绝访问我的点击)。我在我的代码的其他区域使用 jQuery,所以我认为我已经正确链接了它,并且我已经多次检查目标以确保它是一个类并且我使用了正确的语法,但我一定是错过了某物。我觉得我刚刚看了太久了。任何帮助将不胜感激。
HTML:
<h3 class="collapseButton leftH3" data-toggle="collapse" data-target=".collapse_me">
Returns information about the current User
<span class="pull-right" id="arrow_me">
<i class="fa fa-arrow-down" aria-hidden="true"></i>
</span>
</h3>
JS:
function changeArrows() {
$('.collapseButton').on("click", function() {
$(this).next('.pull-right')
.html('<i class="fa fa-arrow-up" aria-hidden="true"></i>');
});
}
changeArrows();
最佳答案
你必须使用 children
而不是 next
function changeArrows() {
$('.collapseButton').on("click", function() {
$(this).children('.pull-right')
.html('<i class="fa fa-arrow-up" aria-hidden="true"></i>');
});
}
关于javascript - jQuery点击麻烦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39711302/