Bootstrap星级评级onclick不要开火 [英] Bootstrap star rating onclick dont fire
问题描述
在我的项目中,我有一个包含很多div的for循环。对于每个div我都有星级评价,我试图触发onclick事件,但它不起作用。我已经尝试了 .live
事件,但它仍无法正常工作。我无法使用我在stackoverflow上看到的所有选项来激活onclick事件。
In my project I have a for loop that has a lot of divs. For each div I have evaluation with the star rating, I'm trying to trigger the onclick event but it doesn't work. I already tryed the .live
event it still didn't work. I just can't fire the onclick event with all the options that I already saw here on stackoverflow.
这是我的代码和脚本
<div class="col-md-3" style="margin-top:40px">
<input name="input-2" value="0" class="rating-loading input-2" data-size="xs">
</div>
$('.input-2').live('click', function () {
console.log("a");
});
推荐答案
如果你检查逐页加载,你不要点击.input-2你点击.rating这样最简单的方式就是这样
if you inspect element after page loads, you don't click on .input-2 you click on .rating so easiest way would be like this
$('。rating' ).on('click',function(){
console.log(a);
});
这篇关于Bootstrap星级评级onclick不要开火的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!