Scott Eldo Scott Eldo - 5 months ago 20
jQuery Question

Activate a dropdown option from another button/llink

I have been struggling to work out how to do this. I have a dropdown on a page that I have no control over code wise -

<select name="dex_item" id="dex_item" onchange="dex_updateItem()">
<option value=1>2016</option>
<option value=4>2017</option>
<option value=5>2018</option>

I want to create a simple button/link that when clicked activates one of the options. So for example when I click #click then the option value=4 is selected.

I have seen examples similar but can't get anything to work...


Maybe I misunderstood but to select a value of the the select input you can use the following code :

$("#click").click(function(e) {


If you want to trigger the onchange event you can do this :

 $(function() {
   $("#click").click(function(e) {
     var select = $("#dex_item");

 function dex_updateItem() {