当我在$(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
。 - Raynos