gpt4 book ai didi

javascript - 为什么我的跨度在单击 JQuery 事件时不会单击它?

转载 作者:行者123 更新时间:2023-11-28 16:38:25 26 4
gpt4 key购买 nike

.tablePlayButton {
display: block;
width: 16px;
background: transparent;
margin-top:2px;
margin-right: -10px;
margin-left: 2px;
height:17px;
}

tr:hover .tablePlayButton {
background: url(ton.png) top left no-repeat;
}

tr:hover .tablePlayButton:active {
background-position: bottom left;
}

tr:hover .tablePlayButton.playing,
.tablePlayButton.playing {
background: url(ton2.png) top right no-repeat;
}

tr:hover .tablePlayButton.playing:active,
.tablePlayButton.playing:active {
background-position: bottom right;
}

我这样画跨度:<span class="tablePlayButton"></span>

它有一个小按钮。当我点击它时,没有任何反应:

$(".tablePlayButton").click(function(){
alert('hi');
});

最佳答案

您可能在创建元素之前添加点击处理程序。

尝试将 Javascript 代码移到元素后面,或将其包装在 $(function() { ... }); 中,以使其在文档加载后运行。

关于javascript - 为什么我的跨度在单击 JQuery 事件时不会单击它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2504727/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com