Jquery mobile 当迁移到JQM 1.1 RC1不工作时,选中单选按钮
为了得到选中单选按钮的值,我使用类似这样的东西Jquery mobile 当迁移到JQM 1.1 RC1不工作时,选中单选按钮,jquery-mobile,radio-button,Jquery Mobile,Radio Button,为了得到选中单选按钮的值,我使用类似这样的东西 $('input:radio[name=rbutton]:checked').val() 在我将jQuery Mobile的版本从1.0升级到1.1 rc1之前,这一切都很好,然后我就无法再获得值,我只得到了“未定义” 我不明白为什么像这样的基本东西不能改变JQM库 我粘贴并举例说明 <!DOCTYPE html> <html> <head> <meta charset="utf-8">
$('input:radio[name=rbutton]:checked').val()
在我将jQuery Mobile的版本从1.0升级到1.1 rc1之前,这一切都很好,然后我就无法再获得值,我只得到了“未定义”
我不明白为什么像这样的基本东西不能改变JQM库
我粘贴并举例说明
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>test radio button</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>
<script>
$(document).delegate("#test", "pageinit", function(event) {
$("button.select").bind ( "click", function (e) {
// Get value of checked radio with JQM 1.0, but get "undefined" with JQM 1.1 RC
alert( $('input:radio[name=rbutton]:checked').val() );
});
$("input[type=radio]").bind ( "change", function (e) {
alert ($(this).val()); //OK
});
});
</script>
</head>
<body>
<div data-role="page" id="test" >
<div data-role="content">
<fieldset data-role="controlgroup">
<input type="radio" name="rbutton" id="rbutton1" value="1" />
<label for="rbutton1">Option 1</label>
<input type="radio" name="rbutton" id="rbutton2" value="2" />
<label for="rbutton2">Option 2</label>
</fieldset>
<button class="select">selected</button>
</div> <!-- /content -->
</div><!-- /page -->
</body>
</html>
测试单选按钮
$(文档).delegate(“#test”,“pageinit”,函数(事件){
$(“button.select”).bind(“click”),函数(e){
//使用JQM 1.0获取已检查无线电的值,但使用JQM 1.1 RC获取“未定义”
警报($('input:radio[name=rbutton]:checked').val();
});
$(“输入[type=radio]”。绑定(“更改”,函数(e){
警报($(this.val());//确定
});
});
选择1
选择2
挑选出来的
这是一个bug,现已修复: