林将一个容器内几个单选按钮,动态地使用jQuery添加方法和添加的事件处理程序,所有的单选按钮,但它不工作事件代表团jQuery的
问:
每当我点击单选按钮在容器内,我需要一组要被执行的命令的..
fiddle- http://jsfiddle.net/Z86kW/1/
Jquery的
$(document).ready(function(){
$('#container').append('<input type="radio" name="radio1"/>');
$('#container').append('<input type="radio" name="radio2"/>');
$('#container').append('<input type="radio" name="radio3"/>');
$("#container").on("click", "radio", function(event) {
alert($(this).text());
})
})
CSS
#container{
height:100px;
width:200px;
background-color:red;
}
HTML
<div id="container">
</div>
,如果你打算使用它就像一个没有无线电集团(同名)复选框,你或许应该使用复选框。 – adeneo
下面是我怎么做 - > http://jsfiddle.net/Z86kW/7/ – adeneo