我想在jquery中选择下拉
列表中所选项目的ID
networkId = $("#availableFbProfiles").selectedIndex.id;
但控制台上的错误是
Cannot read property 'id' of undefined
最佳答案
试试这个:
networkId = $("#availableFbProfiles option:selected").prop("id");
如果您使用旧版本的 jQuery (< 1.7),请使用 attr()
而不是 prop()
。
关于jquery - 如何在jquery中选择selectedIndex的id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10698368/