【发布时间】:2016-11-02 05:06:59
【问题描述】:
我尝试使用 JQuery 添加选项属性。我运行这段代码。
$("option[value='430']").attr("selected","selected");
它返回 TypeError: $(...).attr is not a function(...)
我看不到我的错误。问题出在哪里?
谢谢。
【问题讨论】:
-
Attr或attr???确切的错误信息是什么? -
demo 应该没问题..以及使用
.prop()你应该检查一些其他错误 -
@A.Wolff 我编辑了消息。
-
所以我猜,
$不是指 jQuery -
试试
jQuery("option[value='430']").attr("selected","selected");