前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >使用jQuery

使用jQuery

原创
作者头像
用户8442333
修改2021-05-20 14:38:27
9810
修改2021-05-20 14:38:27
举报
文章被收录于专栏:python知识python知识
jQuery概述
  1. Write Less Do More(用更少的代码来完成更多的工作)
  2. 使用CSS选择器来查找元素(更简单更方便)
  3. 使用jQuery方法来操作元素(解决浏览器兼容性问题、应用于所有元素并施加多个方法)
引入jQuery
  • 下载jQuery的开发版和压缩版
  • 从CDN加载jQuery
代码语言:javascript
复制
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script>
    window.jQuery || 
        document.write('<script src="js/jquery-3.3.1.min.js"></script>')
</script>
查找元素
  • 选择器
    • * / element / #id / .class / selector1, selector2
    • ancestor descendant / parent>child / previous+next / previous~siblings
  • 筛选器
    • 基本筛选器::not(selector) / :first / :last / :even / :odd / :eq(index) / :gt(index) / :lt(index) / :animated / :focus
    • 内容筛选器::contains('…') / :empty / :parent / :has(selector)
    • 可见性筛选器::hidden / :visible
    • 子节点筛选器::nth-child(expr) / :first-child / :last-child / :only-child
    • 属性筛选器:[attribute] / [attribute='value'] / [attribute!='value'] / [attribute^='value'] / [attribute$='value'] / [attribute|='value'] / [attribute~='value']
  • 表单::input / :text / :password / :radio / :checkbox / :submit / :image / :reset / :button / :file / :selected / :enabled / :disabled / :checked
执行操作
  • 内容操作
    • 获取/修改内容:html() / text() / replaceWith() / remove()
    • 获取/设置元素:before() / after() / prepend() / append() / remove() / clone() / unwrap() / detach() / empty() / add()
    • 获取/修改属性:attr() / removeAttr() / addClass() / removeClass() / css()
    • 获取/设置表单值:val()
  • 查找操作
    • 查找方法:find() / parent() / children() / siblings() / next() / nextAll() / prev() / prevAll()
    • 筛选器:filter() / not() / has() / is() / contains()
    • 索引编号:eq()
  • 尺寸和位置
    • 尺寸相关:height() / width() / innerHeight() / innerWidth() / outerWidth() / outerHeight()
    • 位置相关:offset() / position() / scrollLeft() / scrollTop()
  • 特效和动画
    • 基本动画:show() / hide() / toggle()
    • 消失出现:fadeIn() / fadeOut() / fadeTo() / fadeToggle()
    • 滑动效果:slideDown() / slideUp() / slideToggle()
    • 自定义:delay() / stop() / animate()
  • 事件
    • 文档加载:ready() / load()
    • 用户交互:on() / off()

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • jQuery概述
  • 引入jQuery
  • 查找元素
  • 执行操作
相关产品与服务
内容分发网络 CDN
内容分发网络(Content Delivery Network,CDN)通过将站点内容发布至遍布全球的海量加速节点,使其用户可就近获取所需内容,避免因网络拥堵、跨运营商、跨地域、跨境等因素带来的网络不稳定、访问延迟高等问题,有效提升下载速度、降低响应时间,提供流畅的用户体验。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档