我读了很多关于计算器的事情,但没有帮助我:(如何检测这个单选按钮是否被选中?
我有这样的HTML表格,通过Ajax请求加载:
<table class="table table-striped table-hover choix_annonce_table">
<thead>
<tr>
<th>Sélection</th>
<th>Visuel</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="radio" value="45" name="idAnnonce"></td>
<td><img alt="Annonce 1" src=""></td>
</tr>
<tr>
<td><input type="radio" value="46" name="idAnnonce"></td>
<td><img alt="Annonce 2" src=""></td>
</tr>
</tbody>
</table>
我尝试当单选按钮被选中来检测,但没有以下问题的工作(在js文件包括在我的 “主” 页):
$(document).ready(function() {
$("input[name=idAnnonce]").click(function(){
alert("xx");
});
});
OR
$(document).ready(function() {
$("input[name=idAnnonce]:radio").change(function() {
alert("xx");
});
});
你有想法吗?
编辑:当我加载JS直接到我的加载表与Ajax,它的工作原理。 为什么?
的可能的复制【使用方法上的改变事件无线电?(http://stackoverflow.com/questions/13152927/how-to-use-radio -on-change-event) – robbmj
阅读选中的属性? 'console.log(this.checked);' – epascarello
[Find out if if radio button is checked with JQuery?](http://stackoverflow.com/questions/2272507/find-out-if-radio-button-使用jquery进行检查) – Heroselohim