<html><head>
<script>
alert(window.selectType.value); function selectType() {
alert("change");
} </script></head><body><form>
<input type="text" id="selectType" value="1" onchange="selectType();"/></form><script>
alert(window.selectType.value); // function selectType() {
// alert("change");
// }</script></body></html>一次偶尔的机会,写了id和方法名一样,于是后出现了奇葩现象,onchange的时候会报错说selectType不是一个方法。
经过各种调试后,终于发现,如果把form标签删掉,就能正常触发onchange方法。不过window.selectType.value还是依然有错。
可有大神能解释解释这里form标签究竟干了什么?
汪汪一只猫
随时随地看视频慕课网APP
相关分类