Web 前端开发

jQuery选择器

2018-08-02  本文已影响5人  小7丁

一、jQuery 1.x 版本和 2.x 版本有什么区别?

jQuery 1.x 版本代码更老一些,兼容ie6,7,8
2.x代码更精简一些,体积更小一些,只兼容到ie9

二、介绍 jQuery 常见的选择器,以及以下 api 的用法,给出范例

.eq
.next / .prev
.nextAll / .prevAll
.siblings
.parent / .parents
.children / .find
.filter
.has
.is

<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div class="container">
    <div class="test1">1</div>
    <div class="test2">2</div>
    <div class="test3">3</div>
  </div>
</body>
</html>

.eq

image

.next / .prev

image

.nextAll / .prevAll

image

.siblings

image

.parent /.parents

image

.children / .find

image

.filter

image

.is

image

.has

image

三、使用 jQuery 实现 Tab 切换效果

demo

四、使用 原生 js 实现 Tab 切换效果

demo

上一篇 下一篇

猜你喜欢

热点阅读