jquery selected下拉列表返回true或false

jquery selected下拉列表返回true或false,jquery,select,drop-down-menu,selected,Jquery,Select,Drop Down Menu,Selected,我有一个下拉列表,我想使用jquery查看所选的选项中是否有selected字段选项jquery中是否有一种方法可以根据内容返回true或false,您可以使用jquery检查所选项目的所有内容 // get the selected item // note: this is getting the parent 'select' element first and then finding // the selected option within the selects

我有一个下拉列表,我想使用jquery查看所选的选项中是否有selected字段选项jquery中是否有一种方法可以根据内容返回true或false,您可以使用jquery检查所选项目的所有内容

// get the selected item 

// note: this is getting the parent 'select' element first and then finding 
//       the selected option within the selects child elements

var selectedOption = $('select').find('option:selected');

// you could also use a selector to find a specific select within the page, e.g.,
var select = $('select.my-select'); // this will find a select with a class attribute of 'my-select'

// get the text from it
var text = selectedOption.text();

// get the html from it
var html = selectedOption.html();

// get an attribute from it
var classNames = selectedOption.attr('class');
var id = selectedOption.attr('id');

由于该选项有一个id,您可以$'id'。is':selected'Expand your question please…Arun P Johny这正是我想要的,您可以写下这个作为答案吗