我是Jquery的新手,我有以下代码:
jQuery(document).ready(function(){
var title = jQuery(".fullVisaImg").attr("inselect");
var links = jQuery(".ff_elem>option");
for(var i=0; i<links.length; i++) {
if (title == links[i].value) {
links[i].attr("selected", "selected"); // here is my problem
alert(links[i].value);
return;
}
}
});
select
我的页面上有一个元素,并希望选择其中一个元素。如果我对// here...
所有内容都表示赞同,那么我会看到我所有的option
价值观。
感谢帮助!
按照您的代码,您可以使用:
links.eq(i).prop("selected", true);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句