【发布时间】:2015-07-14 16:44:22
【问题描述】:
当我尝试在$(document).ready 中使用$("#div_id") 时它返回NULL,但是当我使用jQuery("#div_id") 时它返回实际对象!
为什么会这样?
更新:我尝试了 noConflict 方法,但没有获得任何提示。
jQuery.noConflict()
function (a,b){return new c.fn.init(a,b)}
$.noConflict();
TypeError: Object function ()
{
return document.getElementById.apply(document, arguments)
} has no method 'noConflict'
更新 2:
$(document).ready(function() {
debugger;
});
<input type="text" id="test" name="test" value="123" />
当我在控制台中运行以下代码时,我得到了这些结果:
$("#test").val()
TypeError: Cannot call method 'val' of null
jQuery("#test").val()
"123"
谢谢
【问题讨论】:
-
听起来像萤火虫被覆盖
$是 document.getElementById -
我在没有启用firebug的情况下加载页面,有时它会提示错误,表明找不到该元素。但其他时候效果很好
标签: jquery