use*_*531 2 javascript jquery google-chrome
以下是我的代码在Firefox中运行良好,但在chrome中没有.请告诉我如何解决这个问题.主要思想是根据选择框的选定值调用js函数:
<select onselect="question_type(this.value);" name="qtype" id="qtype" class="form-control input-lg" required>
<option value="">-- Select question type for this quiz --</option>
<option onclick="question_type(this.value);" value="mcq">1) MCQs</option>
<option onclick="question_type(this.value);" value="tf">2) True/False</option>
</select>
Run Code Online (Sandbox Code Playgroud)
options不会在chrome中激活鼠标事件.
对于select元素,您将onchange在选择本身上使用事件,并且select的值将始终与所选选项相同
<select onchange="question_type(this.value);" name="qtype" id="qtype" class="form-control input-lg" required>
<option value="">-- Select question type for this quiz --</option>
<option value="mcq">1) MCQs</option>
<option value="tf">2) True/False</option>
</select>
Run Code Online (Sandbox Code Playgroud)
用jQuery就可以了
$('select').on('change', function() {
var selected = this.value;
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2332 次 |
| 最近记录: |