开发者

Having trouble programatically selecting a radio button using jQuery in Firefox 5

I'm trying to programatically select a radio button using jQuery 1.4.2. It works in IE 8 and Chrome 12 but doesn't seem to work in Firefox 5.

The HTML for the radio button is:

<input type='radio' name='selected-row'>

The code I'm using is below, where radioButton is a jQuery object.

    onCellSelect: function (rowid, iCol, cellcontent, e) {
        var cell = $(e.srcElement);
        var radioButton = cell.closest("tr").find("input[type='radio']");

        radioButton.click();
    }

I've also tried using the below based on stuff I found googling and that 开发者_运维知识库works in both IE and Chrome, but not Firefox.

 radioButton.attr("checked", "true");
 radioButton.button("refresh");

How does one get this to work in Firefox?


Like takeek's above the following works in Firefox 5

<input id="myRadioButton" type="radio" name="selected-row">

and using works

$('#myRadioButton').attr('checked', true);

Check your radioButton variable is what you expect it to be. How are you selecting your radio button?

Also prop() was only introduced to jQuery in 1.6 so attr() is fine here.


<input type="radio" value="The Answer" name="choices" id="myRadio">

-

$('#myRadio').attr('checked', true);

Works fine for me in Firefox 5. I think your problem must lie elsewhere. Maybe a different firefox-specific error is preventing it from reaching that line.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜