The onclick event does not work for options

后端 未结 5 1547
长情又很酷
长情又很酷 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:22

    A different approach would be add an event listener to the and not the options.

    var e = document.getElementById("qtype");
    var selectedSelect= e.options[e.selectedIndex].value;
    

    the above code will find the select element and call it e. Then find the value selected and call it selectedSelect. Then you can simply pass this value into the question_type() function.

提交回复
热议问题