大佬教程收集整理的这篇文章主要介绍了javascript-在Firefox和IE中触发Onclick事件,但在Chrome中不触发,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<script type="text/javascript">
function showhidefields(value,formobj,epsflag,respflag) {
//alert(epsflag);
if (epsflag==0 && respflag==4) {
document.getElementById("tpnr").style.position = "static";
document.getElementById("tpnr").style.top = "0px";
formobj.tussenPersoonNotext.disabled =false;
formobj.email.disabled =true;
}
</script>
<SELEct name="modulEIDval" class="validate['required']">
<option value="">-- SELEcteer Proces--</option>
<option onclick="showhidefields(this.value,this.form,'<?PHP echo 1; ?>');"
value="<?PHP echo $epsmodules; ?>"><?PHP echo 'MBO'; ?></option>
</SELEct>
我的问题是当我在firefox或IE情况下单击选项时,会触发onclick事件,但在chrome情况下根本不会触发.我也尝试更改函数名称,但没有运气.
提前致谢
解决方法:
选项元素不会在所有浏览器中触发click事件,因此您应该远离依赖它.相反,您可以使用onchange()事件进行选择.你可以用这样的东西
<html>
<head>
<script type="text/javascript">
function changeFunc() {
var SELEctBox = document.getElementById("SELEctBox");
var SELEctedValue = SELEctBox.options[SELEctBox.SELEctedIndex].value;
alert(SELEctedvalue);
}
</script>
</head>
<body>
<SELEct id="SELEctBox" onchange="changeFunc();">
<option value="1">Option #1</option>
<option value="2">Option #2</option>`enter code here`
</SELEct>
</body>`enter code here`
</html>
在您的情况下,您使用
<form id='myForm' action="#">
<SELEct id='mySELEct' name="modulEIDval" class="validate['required']" onchange="showhidefields(this.value,this.form,'0');">
<option value="-">-- SELEcteer Proces--</option>
<option value="1"> 'Klantprocessen'</option>
</SELEct>
</form>
以上是大佬教程为你收集整理的javascript-在Firefox和IE中触发Onclick事件,但在Chrome中不触发全部内容,希望文章能够帮你解决javascript-在Firefox和IE中触发Onclick事件,但在Chrome中不触发所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。