小白求助 求大神指点 为什么代码运行没有改变样式的效果啊

MRJayce MRJayce 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
HTML

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Title</title>
</head>
<body>
<p id="message">Whee!</p>
<script src="scripts/addLoadEvent.js"></script>
<script src="scripts/positionMessage.js"></script>
</body>
</html>
JS代码
addLoadEvent.js
function addLoadEvent(func){
var oldonload=window.onload;
if(typeof window.onload != 'function'){
window.onload=func;
}else{
oldonload();
func();
}
}

positionMessage.js
addLoadEvent(positionMessage);
addLoadEvent(moveMessage);
function positionMessage(){
if(!document.getElementById)return false;
if(!document.getElementById("message"))return false;
var elem=document.getElementById("message");
elem.style.position="absolute";
elem.style.left="50px";
elem.style.top="100px";
}
function moveMessage(){
if(!document.getElementById)return false;
if(!document.getElementById("message"))return false;
var elem=document.getElementById("message");
elem.style.left="200px";
}
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
MRJayce
JavaScript 87,984 成员 224,681 内容