你在你的網站上有原型,它也使用$
。
嘗試:
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 $(...) returns a prototype GLOBAL.Element collection
null
是對象?
Yes
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')});
});
您不應該混合使用像JQuery和Prototype – sdespont