我使用了一个悬停函数,你可以在鼠标悬停时做x,然后做y和mouseout。我正在尝试同样的点击,但它似乎不起作用:
$('.offer').click(function(){
$(this).find(':checkbox').attr('checked', true );
},function(){
$(this).find(':checkbox').attr('checked', false );
});
我希望复选框在单击div
时被选中,如果再次单击则取消选中-单击切换。
发布于 2010-11-13 14:24:59
另一种方法是扩展jquery,如下所示:
$.fn.toggleCheckbox = function() {
this.attr('checked', !this.attr('checked'));
}
然后调用:
$('.offer').find(':checkbox').toggleCheckbox();
发布于 2009-09-23 16:46:49
您可以使用toggle
函数:
$('.offer').toggle(function() {
$(this).find(':checkbox').attr('checked', true);
}, function() {
$(this).find(':checkbox').attr('checked', false);
});
发布于 2010-11-03 00:57:18
为什么不排成一行呢?
$('.offer').click(function(){
$(this).find(':checkbox').attr('checked', !$(this).find(':checkbox').attr('checked'));
});
https://stackoverflow.com/questions/1467228
复制相似问题