为什么我们要用 select 标签来编写.attr('selected','selected')
例如:
$('#countryList option').filter(function () {
return ($(this).text() == findText); }).attr('selected','selected');
});
它的真正含义是什么?
最佳答案
.attr('selected','selected') 的解释
。
.attr 中的第一个参数表示您想要指向的属性
,而第二个参数设置作为第一个参数传递的属性的值
.
如果我们只有 .attr('selected')
那么它只返回 selected
属性的值。
关于jquery - 为什么我们用 select 标签编写 .attr ('selected' ,'selected' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15740986/