您的网站上有原型,并且它也在使用$
.
尝试:
jQuery(document).ready(function($) { // This way you have no conflict with the $. In here $ refers to jQuery. All other places $ refers to document.getElementById (From prototype)
$("#left").css({'height':($("#right").height()+'px')});
});
所以实际上发生的事情是:
$(document) -> document.getElementById(document)* -> null
->
null.ready -> "sidebarheight.js:1 Uncaught TypeError: Object # has no method 'ready'"
* Think $(...) 返回一个原型 GLOBAL.Element 集合
null
是对象吗?
是的
alert(typeof null); // object
和.....
jQuery(document).ready(...
可以短路jQuery(...
:
jQuery(function($) { // This way you have no conflict with the $. In here $ refers to jQuery all other places et's refers to document.getElementById (From prototype)
$("#left").css({'height':($("#right").height()+'px')});
});