我沒有任何線索爲什麼這個解決方案不起作用... 有人可以幫忙嗎?Mootools解決不起作用
下面的代碼:
<html>
<head>
<script type="text/javascript" src="js/mootools-core-1.4.5-full-nocompat.js"></script>
<script>alert($('div#root'));</script>
</head>
<body>
<div id="root"></div>
</body>
</html>
alert函數返回NULL,而不是「對象htmldivobject」
它就像LIKE'document.getElementById' - 不完全等價。在IE> = 8中設置元素存儲,元素uid並將Element.prototype方法複製到實際元素對象。使用'document.getElementById'代替將不起作用 –
謝謝@DimitarChristoff,更正了我的答案。 – Alex
還有'document。 id'方法,它也是'$',你可以用同樣的方法。 –