0
<select name="cat1" class="form-control input-lg">
        <option value="">All Businesses</option>
        <option value="78">Deals</option>
        <option value="46">Delivery</option>
        <option value="45">Dispensary</option>
        <option value="47">Doctor</option>              
</select>

I know you could simply add the selected="selected" to the whatever option to make it default in the drop down. Currently the "All Businesses" option is the default one showing. I want the Dispensary option to show as default

<select name="cat1" class="form-control input-lg">
        <option value="">All Businesses</option>
        <option selected="selected" value="45">Dispensary</option>
        <option value="46">Delivery</option>
        <option value="47">Doctor</option>  
        <option value="78">Deals</option>           
</select>

so basically I want that achieved but I am unable to edit the HTML code. Is there a way I can achieve it without touching the HTML?

AKR
  • 27
  • 8
  • 4
    With CSS, no. With JavaScript yes. Have you tried anything? There's a million resources on the web that will tell you how to selection an option that way. – j08691 Apr 07 '15 at 17:42

1 Answers1

0
$('select[name="cat1"] > option[value="45"]').attr('selected','selected');

This jQuery code will select that option element and add that attribute to it.

ferr
  • 1,137
  • 3
  • 12
  • 28