面试题,自己写写dome总是好的

1、完成如下图所示的布局

面试题,自己写写dome总是好的

 1 <html>

 2 <head>

 3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 4 <style type="text/css">

 5             body, div{margin: 0;padding: 0;}

 6             .fl{float: left; display: inline;}

 7             .bc_C{background-color: #CCC;}

 8             .h120{height: 120px;}

 9             .h250{height: 250px;}

10             .w120{width: 120px;}

11             .w220{width: 220px;}

12             .t0{top:0;}

13             .l0{left:130px}

14             .t130{top: 130px;}

15             .pa{position: absolute;}

16             .mr10{margin-right: 10px;}

17             .mb10{margin-bottom: 10px;}

18             .zi{z-index:-1}

19 </style>

20 </head>

21 <body>

22             <div id="div1"class="zi fl bc_C h120 w120 mb10 mr10 pa"><a href="testdiv.html"></a></div>

23             <div id="div2"class="zi fl bc_C h250 w220 pa t0 l0"></div>

24             <div id="div3"class="zi bc_C h120 w120 t130 pa"></div>

25             <script type="text/javascript"src="../js/testdiv.js"></script> 

26 </body>

27 </html>

2、鼠标移动到div,图片变大为原来的25%

var obj = document.getElementById("div1");

    var w=obj.clientWidth;

    var h=obj.clientHeight;

    obj.onmouseover=function(){

        w=w*1.25;

        h=h*1.25;

        this.style.width=w;

        this.style.height=h;

        this.style.zIndex=1;

        this.style.backgroundColor = "red";

    };

    obj.onmouseout=function(){

        w=w/1.25;

        h=h/1.25;

        this.style.width=w;

        this.style.height=h;

        this.style.zIndex=-1;

        this.style.backgroundColor = "";

    };

 3、jquery实现removeElement()函数

<body>

    <ul>

        <li>a</li>

        <li>b</li>

        <li>c</li>

        <li>d</li>

    </ul>

    <input id="btn"type="button"value="删除元素"></input>

    <script type="text/javascript"src="../js/jquery-1.7.2.js"></script>

    <script type="text/javascript"src="../js/removeElement.js"></script>

</body>
$("#btn").click(function(){

        $("ul li:first").remove();

    });

4、用javascript实现乱序函数randomSort(array)函数,输出排序后的函数。如[1,2,3,4,5],输出[3,2,4,5,1]。要求100次以内不重复。

 

你可能感兴趣的:(dom)