笔试编程题,要先手写代码思路,然后用语言加代码实现
<style type="text/css">
#list {background:red;width:100px;height:100px;padding:0;}
li{list-style:none}
#list.red{background:red}/*<ul id="list" class="red"> 筛选同一个元素*/
#list.yellow{background:yellow}
#list.green{background-color:black}
</style>
</head>
<body>
<ul id="list" class="">
<li id="red"></li>
</ul>
<script type="text/javascript">
var oList=document.getElementById('list');
console.log('112')
oList.className="red";
function apromise(t){
return new Promise(function(resolve,reject){
console.log('113')
setTimeout(resolve,t)
})
}
function stat() {
function stat() {
apromise(3000).then(function () {
console.log('115')
oList.className = "yellow";
console.log('116')
return apromise(1000);
}).then(function () {
oList.className = "green";
return apromise(2000);
}).then(function () {
oList.className = "red";
stat();
})