zeptojs中获取select选中的option的值

第一种方法

// get OPTION elements for which `selected` property is true
$('option').not(function(){ return !this.selected })

问题

:$(‘option[selected]’) only finds options that have their selected attr set in the html.It does not find values the the user has selected themselves.

结论:

This is expected behavior. Such CSS selectors match attribute values, which don’t change with user interaction. Theselected property of the element changes, but attribute doesn’t.

第二种方法

$("#ID").val()  获取选中的value
$("#ID option").eq($("#ID").attr("selectedIndex")).text()    获取选中的文本值

你可能感兴趣的:(option,select,zeptojs)