jquery的作业

Original 2018-12-21 15:21:42 286
abstract:总觉得好多地方  搞不太明白  看着懂 但是操作起来感觉吃力<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Document</title><style type="text/css">*{m

总觉得好多地方  搞不太明白  看着懂 但是操作起来感觉吃力


<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<style type="text/css">

*{margin:0px;padding: 0px;list-style: none;}

ul{list-style: none;z-index:20;position:relative;font-size: 15px;}

li{float:left;cursor:pointer;width:100px;height: 30px;text-align:center;line-height:30px;color: #fff;font-weight: bold;}


.top{width:500px;position:relative;margin:20px auto;height:32px;box-shadow: 0 2px 20px #000;background: #AF3434;border-radius:3px}

.book{z-index: 10;width: 65px;height: 2px;background-color: #fff;margin-left: 7px;position: absolute;top: 30px;}




</style>

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

</head>

<body>

<script type="text/javascript">

$(function(){

$('li').hover(  //获取li标签

          function(){

           $x=parseInt($(this).attr('name'))*100  //定义个变量  parseInt获取this attr获取内部属性  连接name  这句话就是给x定义个变量 给每个name*100   

            $('.book').stop().animate({left:$x+'px'},300)//book为下方的下划线  stop停止   

          },

          function(){

          $('.book').stop().animate({left:'0px'},500)

          }

)

})

</script>

<div>

<ul>

<li name="0">博客1</li>

<li name="1">博客1</li>

<li name="2">博客1</li>

<li name="3">博客1</li>

<li name="4">博客1</li>

<li name="5">博客1</li>


</ul>

<div></div>

</div>

</body>

</html>


Correcting teacher:天蓬老师Correction time:2018-12-21 16:22:33
Teacher's summary:很多同学都有这种问题,看起来懂,实际写的时候又发现不太懂。实际上就是写的太少了。写多了就没有这些问题了

Release Notes

Popular Entries