在Zepto.js中执行.find("option:selected")时出现错误。在Zepto中是否支持":selected“?如果不是,有没有一种等效的方法来实现这一点,而不需要恢复到jQuery?
发布于 2012-02-03 04:44:07
从浏览文档来看,我不这么认为。也就是说,您应该能够做到:
var sel = document.getElementById("mySelect");
console.log(sel.options[sel.selectedIndex].value);发布于 2013-01-09 09:43:37
Zepto的默认模块不支持:selector,因为它不是CSS标准,但您可以为该功能添加‘选择器’Zepto模块(请参阅Zepto Github page以构建带有可选模块的库)。
或者,还有Zepto问题中提到的解决方法:https://github.com/madrobby/zepto/issues/503
// get OPTION elements for which `selected` property is true
$('option').not(function(){ return !this.selected })发布于 2012-02-03 06:16:33
试试看起来很适合我的$('select').val();。
https://stackoverflow.com/questions/9119581
复制相似问题