我得到了这个脚本:
<script>
$(document).ready(function () {
$('a[@href^= ""] img').parent().click(function () {
var linkz = $(this).attr("href");
if(linkz.toLowerCase().indexOf("http: //www.website.com") >= 0) {
window.open($(this).attr("href"));
return false;
} else {
window.open("http://www.website.com/p/img.html?img=" + $(this).attr("href "));
return false;
}
});
});
</script>
要在新页面中打开所有图像,请在新链接中传递图像 URL。但我得到了
TypeError: $ is not a function.
我尝试添加 jQuery(document) 而不是 $(document) 但后来我得到了
$('a[@href^=""] img')
TypeError: $ is not a function
这里。
最佳答案
要么你没有包含 jQuery,要么你运行了 noConflict() 并且它释放了对 $ 的控制。
http://api.jquery.com/jQuery.noConflict/
如果您使用了 noConflict,则只需始终使用 jQuery(),包括 jQuery('a[@href^=""] img')。
关于javascript - Jquery 类型错误 : $ is not a function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15672922/