javascript onclick函数未定义Internet Explorer
问题描述:
我一直在寻找这个问题的几个小时。 我的JavaScript代码在Chrome,Firefox和Edge上运行良好,但在Internet Explorer上无法运行。 该功能在Internet Explorer上未定义。我知道已经有很多关于它的话题,但在我的案例中没有一个能够起作用。javascript onclick函数未定义Internet Explorer
function it_do_not_work()
{
alert('Not working');
}
<div class="submit-petsitter-selection">
<input type="submit" id="submit-petsitter-selection" class="btn btn-red-search" name="PetSittersSelection" data-selected-petsitters-none="@Translation.C03b_NumberOfSelectedPetSittersNone" data-selected-petsitters-singular="@Translation.C03_NumberOfSelectedPetSittersSingular" data-selected-petsitters-plural="@Translation.C03a_NumberOfSelectedPetSittersPlural" onclick="it_do_not_work();" />
</div>
答
我找到了解决办法。这是Internet Explorer的兼容性。我补充说:
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
+0
你意识到[条件注释已被弃用](https://msdn.microsoft.com/en-us/library/hh801214(v = vs 0.85)的.aspx)? – Liam
不知道它是否是一个错字,但你有两个开放? – delinear
我打错了,但我没有忘记它在项目中^^' –