Trigger change event <select> using jquery

前端 未结 8 1050
别那么骄傲
别那么骄傲 2020-11-28 04:27

is there anyway i could trigger a change event on select box on page load and select a particular option.

Also the function executed by adding the trigger after bin

相关标签:
8条回答
  • 2020-11-28 05:01

    To select an option, use .val('value-of-the-option') on the select element. To trigger the change element, use .change() or .trigger('change').

    The problems in your code are the comma instead of the dot in $('.check'),trigger('change'); and the fact that you call it before binding the event handler.

    0 讨论(0)
  • 2020-11-28 05:06

    Give links in value of the option tag

    <select size="1" name="links" onchange="window.location.href=this.value;">
       <option value="http://www.google.com">Google</option>
       <option value="http://www.yahoo.com">Yahoo</option>
    </select>
    
    0 讨论(0)
提交回复
热议问题