jquery不会预加载IE 7中的单选按钮

jquery不会预加载IE 7中的单选按钮,jquery,internet-explorer,input,radio-button,Jquery,Internet Explorer,Input,Radio Button,我试图用从jQueryAjax调用中检索的数据预填充表单。数据很好,但在使用IE 7时,我无法检查正确的单选按钮 以下代码在Firefox、Safari和Chrome中运行良好 Lets assume data.description = 'student' // I have tried both of these with no luck in IE 7 $("input[value='"+data.description+"']").attr('checked', true); $("i

我试图用从jQueryAjax调用中检索的数据预填充表单。数据很好,但在使用IE 7时,我无法检查正确的单选按钮

以下代码在Firefox、Safari和Chrome中运行良好

Lets assume data.description = 'student'

// I have tried both of these with no luck in IE 7
$("input[value='"+data.description+"']").attr('checked', true);
$("input[name='self_description']").filter("[value='"+data.description+"']").attr('checked', true);

<div><label><input type="radio" name="description" value="student">student</label></div>
<div><label><input type="radio" name="description" value="part time">part-time</label></div>
假设data.description='student'
//我尝试过这两种方法,但在IE 7中没有成功
$(“输入[value=”+data.description+“]”).attr('checked',true);
$(“input[name='self_description']”。filter(“[value='”+data.description+']”)。attr('checked',true));
学生
兼职的

您的筛选器表达式似乎缺少一个方括号,应该引用文本。尝试:

$("input[name='self_description']").filter("[value='"+data.description+"']").attr('checked', true);
编辑:

我想到的另一件事是,一旦DOM就绪,就执行以下操作:

$(document).ready(function () {
    // your code here
});

您的筛选器表达式似乎缺少一个开放的方括号,应该引用文字。尝试:

$("input[name='self_description']").filter("[value='"+data.description+"']").attr('checked', true);
编辑:

我想到的另一件事是,一旦DOM就绪,就执行以下操作:

$(document).ready(function () {
    // your code here
});

jquery位于通过文档调用的函数中。ready@peledies-您是否尝试正确引用
数据。说明
.filter(“[value=”+data.description+“]”)
很好的建议,但这并不能解决问题。我应该指出,这种方法对于复选框非常有效。jquery位于通过文档调用的函数中。ready@peledies-您是否尝试正确引用
数据。说明
.filter(“[value=”+data.description+“]”)
很好的建议,但这并不能解决问题。我应该指出,这种方法适用于复选框。