Guys i want to ask how can i make a function in jQuery when i click a button to trigger a select of an option in a select menu.
Here is my HTML code:
<select id="target_menu" name="sort_by">
<option selected="selected" id="position" value="http://cosmeo.superweb.bg/index.php/priceslider/slider/view/?dir=asc&id=35&max=424&min=0&order=position">Позиция</option>
<option id="name" value="http://cosmeo.superweb.bg/index.php/priceslider/slider/view/?dir=asc&id=35&max=424&min=0&order=name">Име</option>
<option id="price" value="http://cosmeo.superweb.bg/index.php/priceslider/slider/view/?dir=asc&id=35&max=424&min=0&order=price">Цена</option>
<option id="color" value="http://cosmeo.superweb.bg/index.php/priceslider/slider/view/?dir=asc&id=35&max=424&min=0&order=color">Color</option>
<option id="created_at" value="http://cosmeo.superweb.bg/index.php/priceslider/slider/view/?dir=asc&id=35&max=424&min=0&order=created_at">Дата</option>
</select>
The option which i want to be triggered as selected is created_at
.
Here is the code of the button that i want when it is clicked to select option with id created_at
of select menu with id target_menu
:
<button onclick="triggerChange()" class="FirstFilter">
Click me!
</button>
When i click on the button -> Click Me!
i want jQuery to force/trigger a selection of option with id created_at
at select menu with id target_menu
.
How my function triggerChange()
must look like ?
So guys, how can i make it?