選択フィールドで特定のオプション/値が選択されているかどうかを確認して、 。私が作成した特定のオプション/値が選択フィールドで選択されたときにhtml要素のクラスを変更します
<select onchange="wow(this.value)">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
<div id="x" class="hide">x</div>
<script>
function wow(value) {
switch (value) {
case "c":
document.getElementById("x").setAttribute("class", "show");
break;
default:
document.getElementById("x").setAttribute("class", "hide");
break;
}
}
</script>
は/ここで働い例http://jsfiddle.net/CVxP7/112/をフォークが、私はselectタグに直接のonchangeイベントをコールする必要はありません。
これは、EventListenerまたは別のトリガーを使用して行うことができますか? 私はプレーンなjavascriptまたはmootoolsを使用する必要があります。