checkbox与href勾选问题 part 2 不要直接修改checked属性 如果没选中click 多选框试试 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $('.test_class input[type=checkbox],#show_img').on('click',function(){......}); 跑foreach不行,值带不过去,var check判定也失效<?php foreach((array)$array as $arrays): ?><ul> <li> <label> <input type="checkbox" id="<?php echo $arrays['id'];?>" value="<?php echo $arrays['id'];?>" > <a id="show_img<?php echo $arrays['id'];?>" style="text-decoration: none" href="images/prod/<?php echo $arrays['img'];?>" onclick="document.getElementById('<?php echo $arrays['id'];?>').checked=!document.getElementById('<?php echo $arrays['id'];?>').checked;return false;"> <?php echo $arrays['name']?></a> </label> </li><script>$(function() { $("#show_img<?php echo $arrays['id'];?>?>").powerFloat({ targetMode: "ajax", targetAttr: "href", hoverFollow: "y", position: "2-1" });});$(function(){ $('.test_class input[type=checkbox],#show_img<?php echo $arrays['id'];?>?>').on('click',function(){ var check = ($(this).attr('checked')=='checked')?1:0; if(check==1){ add(); }else{ del(); } }); })</script></ul><?php endforeach; ?> var check = $(this).is(':checked')?1:0; 改var check = $(this).is(':checked')?1:0;,一样问题 $(function(){ $('.test_class input[type=checkbox],#show_img').on('click',function(){ $("#test_1").is(':checked')?add():del(); }); }) $('#show_img').click(function(){ document.getElementById('test_1').checked=!document.getElementById('test_1').checked; $('#test_1').change(); return false;})html里面的oncllick去掉吧。通过JS修改选中checkbox的勾选状态是不会触发他的chang事件的 To : functionsub,还有一点问题,点point me勾选没反应,点连结外有反应 不是叫你把html里a标签的onclick拿掉吗? 不是叫你把html里a标签的onclick拿掉吗?有拿掉 不是叫你把html里a标签的onclick拿掉吗?有拿掉不知道你了,我这里测试正常。 谁来帮帮忙???JS,window.open,window.onunload,about:blank 为什么第二种方法有错误?求指点 求一个JS写的文本编辑器 js 限制同一ip一段时间内不能重复提交表单 解决给分!!! window.opener给前一网页传值时不支持框架吗? 怎么做一个链接点上去弹出保存页面的对话框? 正则表达式,读取字符串内容 鼠标的左右键功能开发,今天解决就结贴! 我想创建一个只有标题栏的页面,请问要如何设置网页属性! 关于xmlHttp.setRequestHeader的问题 大神们是时候表演真正的技术了 这个hover颜色到底在哪
......
});
<ul>
<li>
<label>
<input type="checkbox" id="<?php echo $arrays['id'];?>" value="<?php echo $arrays['id'];?>" > <a id="show_img<?php echo $arrays['id'];?>" style="text-decoration: none"
href="images/prod/<?php echo $arrays['img'];?>"
onclick="document.getElementById('<?php echo $arrays['id'];?>').checked=!document.getElementById('<?php echo $arrays['id'];?>').checked;return false;">
<?php echo $arrays['name']?></a>
</label>
</li>
<script>
$(function() {
$("#show_img<?php echo $arrays['id'];?>?>").powerFloat({
targetMode: "ajax",
targetAttr: "href",
hoverFollow: "y",
position: "2-1"
});
});$(function(){
$('.test_class input[type=checkbox],#show_img<?php echo $arrays['id'];?>?>').on('click',function(){
var check = ($(this).attr('checked')=='checked')?1:0;
if(check==1){
add();
}else{
del();
}
});
})
</script>
</ul>
<?php endforeach; ?>
$(function(){
$('.test_class input[type=checkbox],#show_img').on('click',function(){
$("#test_1").is(':checked')?add():del();
});
})
document.getElementById('test_1').checked=!document.getElementById('test_1').checked;
$('#test_1').change();
return false;
})
html里面的oncllick去掉吧。通过JS修改选中checkbox的勾选状态是不会触发他的chang事件的
不是叫你把html里a标签的onclick拿掉吗?
不是叫你把html里a标签的onclick拿掉吗?
有拿掉
不是叫你把html里a标签的onclick拿掉吗?
有拿掉
不知道你了,我这里测试正常。