我正在尝试使用以下代码在 View 中隐藏/显示元素:
$('buttonClass/IDhere').click(function (){
$('theDivYouWantToShowClass/IDhere').toggle();
});
然而,我不断得到
Microsoft JScript runtime error: '$' is undefined
可能是什么问题,我该如何解决?
最佳答案
这个线程很旧,但我认为线程中的答案会很好。我同意前两个答案 - 可能是因为未加载 jQuery。您可以通过这种方式加载它(通常朝向文件的顶部):
<script src="~/Scripts/jquery-1.9.1.js" type="text/javascript"></script>
<script src="~/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
(或任何当前版本的 jQuery)。
希望能帮助到你。
关于jquery-mobile - Microsoft JScript 运行时错误 : '$' is undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8530311/