码迷,mamicode.com
首页 > Web开发 > 详细

jQuery

时间:2016-05-19 00:07:29      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:

选择元素:

$()

css()

省略原生的循环操作

$ == jQuery

jQuery方法函数化:

click()

html()

JS与jQ关系:

可以共存,不能混写

函数中this是原生的,$(this)转换为jQ对象

技术分享
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style>
    div{
        width: 100px;
        height: 100px;
        float: left;
        border: 1px solid #333;
    }
    </style>
</head>
<body>
    <span>red</span>
    <span>blue</span>
    <span>green</span>
    <span>yellow</span>
    <br>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <script src="jquery-1.11.1.js"></script>
    <script>
    var color = ‘‘;
    $(span).click(function(){
        color = $(this).html();
    });
    $(div).click(function(){
        $(this).css(backgroundColor,color);
    });
    </script>
</body>
</html>
View Code

 

jQuery

标签:

原文地址:http://www.cnblogs.com/jiujiaoyangkang/p/5506963.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!