jQuery11

jQuery介绍

jQuery是一个快速,小巧,功能丰富的JavaScript库。它通过易于使用的API在大量浏览器中运行,使得HTML文档遍历和操作,事件处理,动画和Ajax更加简单。通过多功能性和可扩展性的结合,jQuery改变了数百万人编写JavaScript的方式

jQuery下载

下载地址

https://www.bootcdn.cn/jquery/

开发环境推荐使用

https://cdn.bootcss.com/jquery/3.3.1/jquery.js

生产环境推荐使用(min版本)

https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js

jQuery基本选择器

代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="jQuery.js"></script>
</head>
<body>
<button>按钮</button>
<div class="box" id="box">wanglan</div>
<script>
    //id选择器 设置单一属性
    // $('#box').css('color', 'red')
    //id选择器 设置多个属性
    $('#box').css({
        'color':'red',
        'background-color':'green'
    });
    //类选择器 获取值
    console.log($('.box').css('color'))
    //标签选择器 内部便利
    $('button').click(function () {
        $(this).css('color','darkgreen')
    })
</script>

</body>

</html>

猜你喜欢

转载自www.cnblogs.com/wanglan/p/10242020.html