<tab切换><!doctype html><html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <title>Document</title> <style type="text/CSS"> *{ margin:0; padding: 0; text-align:center; } .box{ width:800px; height:300px; border:1px solid #000000; margin:0 auto; } .box ul{ height:100px; width:100%; display: flex; } .box ul li{ flex:1; height:100%; list-style: none; font:20px/100px ""; } .box ul li:hover{ background:#006400 ; } #photo{ width:100%; height:200px; display: flex; } #photo span{ flex:1; } </style> </head> <script type="text/javascript"> window.onload=function(){ var _li=document.querySelectorAll("#ul li");//得到所有li var _photo=document.querySelectorAll("#photo span"); for (i=0;i<_li.length;i++){ _li[i].index=i; _li[i].onmouSEOver=function(){ for(i=0;i<_photo.length;i++){ _photo[i].style.display = "none"; } _photo[this.index].style.display = "block"; } }} </script> <body> <div class = "box"> <ul id="ul"> <li>red</li> <li>yellow</li> <li>black</li> <li>pink</li> </ul> <div id="photo"> <span style = "background:red">1</span> <span style = "background:yellow">2</span> <span style = "background:black">3</span> <span style = "background:pink">4</span> </div></div> </body></html> //数组去重var arr = [1,2,3,4,1,2]; function removeArr(arr){ var tmp = {}; var newArr = []; for(i=0;i < arr.length; i++){ if(!tmp[arr[i]]){ tmp[arr[i]] = true; newArr.push(arr[i]); } } console.log(newArr); } //removeArr(arr); //异步for(var i = 0; i <= 3; i++){ setTimeout(function(){ //console.log(i)//4444 },0) } for(var i = 0; i <= 3; i++){// setTimeout(// console.log(i)//0123// ,0) } //变量提升var s = 1; function a (){ //console.log(s);//undefined var s = 3; //console.log(s++);//3 } function b(){ //console.log(s);//1 s++; //console.log(++s);//3 } if(100 < 0 <0){ a(); }else{ b(); } if(0 < 1 < (0+4)){ a(); }else{ b(); } //冒泡排序var bubbleArr = [1,3,4,2,6]; function bubble (bubbleArr){ var tmp; for(var i = 0,j = bubbleArr.length; i < j; i++){ for(var k = 1; k < i; k++){ if(bubbleArr[i] < bubbleArr[k]){ tmp = bubbleArr[i]; bubbleArr[i] = bubbleArr[k]; bubbleArr[k] = tmp; } } } console.log(bubbleArr); } //字符串倒序var str = "1,3,4,5,6,7,8"; console.log(str.split(",").reverse().join(" ")) var string = str.split("").reverse().join(''); str.split("")//把字符串分割成数组,如果无参数则每个元素都会被分割,有参数以参数分割 console.log(string);《未完待续》
新闻热点
疑难解答