The onclick event does not work for options

后端 未结 5 1536
长情又很酷
长情又很酷 2020-12-02 02:27

Following is my code which works fine in firefox but not in chrome. Kindly let me know how to solve this issue. The main idea is to call a js function based on the selected

5条回答
  •  旧巷少年郎
    2020-12-02 03:29

    options don't fire mouse events in chrome.

    For a select element you'd use the onchange event on the select itself, and the value of the select will always be the same as the selected option

    
    

    with jQuery it would be

    $('select').on('change', function() {
        var selected = this.value;
    });
    

提交回复
热议问题