Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - Check If any select option is selected

Tags:

Basically I have a select option which pulls all the 'Tour Names' from a database as $touroptions. $touroptions can contain anything from 1-20 values (select options).

What I need to do is have a jQuery function to do as follows so:-

If (any option) #sel-destination-tour is selected { //DO SOMETHING } ELSE { //DO SOMETHING ELSE } 

I'm just not sure how I could do this.

HTML

<select name="sel-destination-tour" id="sel-destination-tour" class="input-select-tour">      <option value="0"></option>      <?php echo $touroptions ?>  </select> 
like image 381
nsilva Avatar asked Mar 27 '13 12:03

nsilva


1 Answers

You can check whether a option by testing the value attribute of the select

if($('#sel-destination-tour').val()){     // do something } else {     // do something else } 
like image 70
Arun P Johny Avatar answered Oct 06 '22 05:10

Arun P Johny