现在的位置: 首页 > 综合 > 正文

$ is not a function 已解决

2013年09月18日 ⁄ 综合 ⁄ 共 688字 ⁄ 字号 评论关闭

网上查资料和不断尝试,终于找到原因了.

1)网上一种解释:

If you are trying to add your own jQuery code to WordPress, and have had the error “$ is not a function” show up on Firebug, here is the fix:

Convert all dollar signs ($) to ‘jQuery’

The dollar sign is reserved in WordPress for the Prototype library, which is why it errors out. For example, instead of:


1
2
3
$().ready(function() {
   $("#select_me").show();
});

Change it to:

1
2
3
jQuery().ready(function() {
   jQuery("#select_me").show();
});

2)按照上面该法没作用. Error msg 变成: jQuery(***).dialog is not a function.

一个下午的努力, 觉得可能是js冲突所致.  一行行删代码, 发现是下面一行. 原来不是方法冲突, 而是引用冲突吧?!

"<script src="<session:constant name='ContextPath'/>/js/jquery-1.8.5/js/jquery-1.4.2.min.js" type="text/javascript"></script>". 在内部Frame的jsp中, 这样一行删除就OK了. 可能是外部已经引用了, 删除后jQuery的方法都正常了.

抱歉!评论已关闭.