在 Firefox 5 中使用 jQuery 以编程方式选择单选按钮时遇到问题
我正在尝试使用 jQuery 1.4.2 以编程方式选择单选按钮。它适用于 IE 8 和 Chrome 12,但似乎不适用于 Firefox 5。
单选按钮的 HTML 为:
<input type='radio' name='selected-row'>
我正在使用的代码如下,其中 radioButton 是一个 jQuery 对象。
onCellSelect: function (rowid, iCol, cellcontent, e) {
var cell = $(e.srcElement);
var radioButton = cell.closest("tr").find("input[type='radio']");
radioButton.click();
}
我还尝试使用以下基于我在谷歌搜索中找到的内容的内容,该内容适用于 IE 和 Chrome,但不适用于 Firefox。
radioButton.attr("checked", "true");
radioButton.button("refresh");
如何让它在 Firefox 中运行?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
与上面的 takeek 一样,以下内容在 Firefox 5 中有效
,并使用有效
检查您的 radioButton 变量是否符合您的预期。您如何选择单选按钮?
另外 prop() 只在 1.6 中引入到 jQuery,所以 attr() 在这里就可以了。
Like takeek's above the following works in Firefox 5
and using works
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.
-
我在 Firefox 5 中工作得很好。我认为你的问题一定出在其他地方。也许是另一个特定于 Firefox 的错误阻止了它到达该行。
-
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.