문제

Instead of writing a temporary boolean, an $.each() on an array of <select> elements, and find if one's prop('selectedIndex') > 0, I'd like to do something like:

$('select[id^="idPrefixForTheArrayOfSelects-"][selectedIndex="0"]').length == 0

but it doesn't work.

Is it possible to select by value, selectedIndex, etc?

도움이 되었습니까?

해결책

You can do this -

$('select[id^="idPrefixForTheArrayOfSelects-"]').filter(function(){
 return this.selectedIndex === 0;
}).length == 0
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top