1
<ul data-role='listview' data-inset='true' data-divider-theme='b'>
    <li data-role='list-divider'>
        <label>Radio Button</label>
    </li>
    <li data-theme='c'>
        <fieldset data-role='controlgroup'>
            <input id='radio1' type='radio' name='Delete' />
            <label for='radio1'>Radio 1</label>
            <input id='radio2' type='radio' name='Delete' />
            <label for='radio2'>Radio 2</label>
        </fieldset>
    </li>
</ul>
<div data-role='navbar'>
    <ul data-inset='true'>
        <li><a data-role='button' href='#' id='delete' data-icon='check'>Ok</a></li>
        <li><a data-role='button' href='#' id='Cancel' data-icon='delete'>Cancel</a></li>
    </ul>
</div>

$("input[type='radio']").checkboxradio("refresh");
var radTrn = $("#radio1").attr('checked');//here it is coming as undefined
var radRstAl = $("#radio2").attr('checked');//here it is coming as undefined    

i m using jquery mobile simple dialog box RAW HTML mode.The radio button checking was working in jquery 1.6.4 and in 1.7.1 it was not working

4

3 回答 3

4

尝试这个:

$('#check').prop('checked');

然后结帐http://api.jquery.com/prop/

于 2012-03-14T04:54:30.593 回答
0
$('#check').attr('checked'); 

problem with quotes..i dont see any other compability issue..

You also try $('#check').is(':checked')

于 2012-03-14T04:52:22.217 回答
0

如果这不是一个简单的格式问题(那里有一个额外的引号),我猜该checked属性没有分配值。这仍然是有效的 HTML,但它可能会影响 jQuery 的齿轮。

幸运的是,您的测试有一个相当简单的解决方法。只需使用:checked伪类如下:

var isChecked = $('#check').is(':checked');

这将返回一个布尔值(true如果选中false则返回),因此您可以将其用作运算符。

于 2012-03-14T04:54:18.483 回答