html:
<div id='logindiv' width=300 height=500><form....></form></div>js:$("<div/>").load('/getform/',{},function(i){
alert($(‘#logindiv').width);
});
这里load能拿到那个div,但是$(‘#logindiv').width打印出来却是:function (K) {
return this[0] == l ? document.compatMode == "CSS1Compat" &&
document.documentElement["client" + G] ||
document.body["client" + G] : this[0] == document ? Math.max(document.documentElement["client" + G], document.body["scroll" + G], document.documentElement["scroll" + G], document.body["offset" + G], document.documentElement["offset" + G]) : K === g ? this.length ? o.css(this[0], J) : null : this.css(J, typeof K === "string" ? K : K + "px");
}
不知道为什么?
alert($(‘#logindiv').width());
});
$('#logindiv').width()或者 $('#logindiv').attr("width")
现在用width()能拿到长度,但打印出来是0?
如果用getAttribute('width'),程序跑不过去。
我把$('#logindiv')打印出来,确实是拿到这个div。
$('#logindiv').attr("width");一般情况下是可以的