<div>
当从此 if 语句调用函数时,我试图调整 a的大小。我知道该if
语句有效,因为当mTr()
调用该函数时它有效,并且我知道该函数myFun()
有效,但由于某种原因,函数 myFun() 没有被调用。
if (window.screen.height==568) { // iPhone 4"
document.querySelector("meta[name=viewport]").content="width=320.1";
myFun("divId");
mTr();
}
function myFun(id)
{
var obj = document.getElementById(id);
if (obj)
{
obj.setAttribute("style", "height:300px;");
}
}
function mTr()
{
alert("Hello World!");
}