遇到了绑定问题
摘录自html代码
<table>
<tr>
<td haschildren="true"><input id="Grubbel_0" type="radio" name="Grubbel_0" value="0"></td>
<td haschildren="true"><input id="Grubbel_1" type="radio" name="Grubbel_1" value="1"></td>
</tr>
</table>
<img src="img.jpg" style="display:none;"/>
一些jQuery
<script language="javascript" type="text/javascript">
$(document).ready(function () {
// Check radiobuttons when clickin on a parent table cell
$("td[haschildren='true']").click(function () {
$(this).find('input:radio').attr('checked', true);
});
// What happens when a radiobutton is changed
$('*[haschildren="true"] input:radio').bind('change', function () {
// This does not work when clicking the td boxes
});
});
</script>
绑定('更改'...当我直接点击收音机盒时工作但是当我点击td时却没有,尽管放射对象被检查了。
我正在使用jQuery 1.5.2。
由于
答案 0 :(得分:4)
尝试 -
$(document).ready(function () {
// Check radiobuttons when clickin on a parent table cell
$("td[haschildren='true']").click(function () {
$(this).find('input:radio').attr('checked', true).trigger('change');
});
// What happens when a radiobutton is changed
$('*[haschildren="true"] input:radio').bind('change', function () {
// This does not work when clicking the td boxes
});
});
答案 1 :(得分:0)
小语法错误将$("td[haschildren="true"]")
更改为$("td[haschildren='true']")