JQuery动画学习的总结

Original 2018-12-13 14:39:37 255
abstract:     通过颜色自动变化实例的学习回顾了之前的知识点,同时回顾了之前JS的知识,这个随机函数jQuery也只是用到了mousemove和mouseleave两个事件,用到了jQuery的基础选择器,通过css改变样式,随机颜色实例如下:<!DOCTYPE html> <html> <head> <meta 

     通过颜色自动变化实例的学习回顾了之前的知识点,同时回顾了之前JS的知识,这个随机函数jQuery也只是用到了mousemove和mouseleave两个事件,用到了jQuery的基础选择器,通过css改变样式,随机颜色实例如下:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>随机变色</title>
<link rel="shortcut icon" type="image/x-icon" href="../picture/mi.png">
<script type="text/javascript" src="jquery-3.3.1.min.js"></script>
<style type="text/css">
    *{margin: 0px;padding: 0px;}
    /*a标签的样式*/
a{text-decoration: none;float: left;width: 100px;height: 100px;border-radius: 50px;/*background-color: pink;*/text-align: center;margin: 50px;}
}
</style>
<script type="text/javascript">
function aa(tag) {
// 获取随机色以RGB颜色为例
           var len=document.getElementsByTagName(tag).length
           for(var i=0;i<len;i++){
            document.getElementsByTagName(tag)[i].style.backgroundColor='rgb('+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+')'
           }
        }
        $(document).ready(function(){
         aa('a');
         $('a').mousemove(function(){
         //鼠标移上后改变形状
         $bg=$(this).css('backgroundColor')
         $(this).css('box-show','0px 0px 20px');
         $(this).css('borderRadius','10px');
         })
         $('a').mouseleave(function(){
         // 鼠标离开后变回原来的形状
         $(this).css('borderRadius','50px');
         })
        })

</script>
</head>
<body>
<a href="#"></a>
<a href="#"></a>
<a href="#"></a>
<a href="#"></a>
<a href="#"></a>
</body>
</html>


Correcting teacher:韦小宝Correction time:2018-12-13 14:57:23
Teacher's summary:不错不错!代码写的很完整!jquery中的动画是个很好玩的效果!课后记得多练习哦!

Release Notes

Popular Entries