Javascript JQuery select选择之Safari与Firefox

发现在苹果IOS手机及Safari浏览其中,如下代码不工作。

$("#users option[value='hello']").attr("selected",true);

换成

$("#users option[value='hello']").prop("selected",true);

就可以了,2个浏览器都没问题。

原文地址:https://www.cnblogs.com/bjfarmer/p/13575820.html