简体   繁体   English

jQuery旧版本和较新版本中的select值(禁用的选项)中的差异

[英]Discrepancies in select value(disabled option) in jQuery old and newer version

I have updated jquery version from 1.7.2 to 2.1.1 in my project and used jquery migrate for fallback. 我已经在项目中将jquery版本从1.7.2更新到2.1.1,并使用了jquery migration作为后备。

I found an issue related to value of select in jQuery 2.1.1 and 1.7.2. 我在jQuery 2.1.1和1.7.2中发现了与select值有关的问题。

1.7.2 --> "" (Blank) 1.7.2->“”(空白)

2.1.1 --> null 2.1.1->空

Codepen 码笔

console.log("Version>>> 1.7.2 >>>> " + $jq("select").val());
console.log("Version>>> 2.1.1  >>> " + $("select").val());

Has anyone come around the similar issue and its workaround? 有没有人遇到类似的问题及其解决方法?

PS : I am using Native JS for the time being to make it work. PS:我暂时使用Native JS使其正常工作。

使用:selected jquery选择器,您将得到什么?

$("select option:selected")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM