Javascript and JQuery, how to verify if option element exists in select?

前端 未结 3 942
梦如初夏
梦如初夏 2021-01-12 07:28

Using JQuery, I\'m trying to set an option as selected in a \'select\' element based on the query string.

This question is similar to this, however I still need to k

3条回答
  •  北恋
    北恋 (楼主)
    2021-01-12 08:23

    try to check selectObject.find('option[value="'+valueToSelect +'"]').length > 0

提交回复
热议问题