|
我还参考别人的代码找到另外一种方法,可以同时修改很多层的数据,就是定义一个层,如<div id="aaa"></div> ,然后对aaa赋值,不局限于一个变量,可以是一些层,一个功能模块,贴出来供和我一样的新手参考,高手就可以忽略。再次感谢大家对我问题的回答。完整代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>frame</title>
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<link rel="stylesheet" type="text/css" href="../css/api.css" />
<link rel="stylesheet" type="text/css" href="../css/common.css" />
<style>
html, body {width: 100%;min-height: 100%;background: #f0f0f0;}
/* 头部登陆 */
.login {position:relative;background-image: url(../image/api_31.png);background-repeat: no-repeat; background-size: contain;}
.loginbg { width: 100%;}
.login .personal_logo {position: absolute; left:0;top: 55px; width: 70px; margin-left: 20px;}
.person_arrow {position: absolute;height: 20px; right: 10px; top: 90px;}
.login .userinfo {position: absolute; top: 60px; margin-left: 100px;}
.login .userinfo .subtitle {font-size: 14px; color: #fff;border: 1px solid #fff;display: inline-block;padding: 3px;border-radius: 4px;margin-top: 5px;}
</style>
</head>
<body>
<div class="login" onclick="" tapmode>
<div class="userinfo">
<!-- 需要在下面层里面调用username变量,显示 “谢谢大家”四个字 *-->
<div id="aaa"></div>
</div>
<img src="../image/personal_icon_arrow.png" alt="" class="person_arrow">
</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
apiready = function () {
var username="谢谢大家";
var html = '';
var obj = $api.byId('aaa');
html += '<div class="subtitle">'+username+'</div>';
$api.html(obj, html);
}
</script>
</html> |
|