美文网首页
day9_JavaScript+JQuery

day9_JavaScript+JQuery

作者: KingJX | 来源:发表于2018-08-23 19:09 被阅读0次
    • 获取可视区的宽度和高度

    获取宽高的时候,要看有没有DTD的说明,如果有,使用documentElement,如果没有,使用body

    var clientWidth = document.documentElement.clientWidth
    var clientHeight = document.documentElement.clientHeight
    
    • 1、吸顶条

    可以直接获取到div的宽度和高度,而且是不带px, 并且样式无论在哪都可以获取到,这两个属性是只读属性
    offsetWidth
    offsetHeight
    可以直接获取到div的距离浏览器上边的距离和距离浏览器左边的距离,而且是不带px, 并且样式无论在哪都可以获取到,这两个属性是只读属性
    offsetTop
    offsetLeft

    • 2、jquery

    • jquery是什么?

      jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.
      jQuery是一个快速、小型、功能丰富的JavaScript库。它使HTML文档遍历和操作、事件处理、动画和Ajax等工作变得更加简单,并且具有在多个浏览器之间工作的易于使用的API。结合了通用性和可扩展性,jQuery改变了数百万人编写JavaScript的方式。

      • 压缩和非压缩
        .min.js : 压缩版本,一行代码,没有了空格、缩进等
        .js : 非压缩版本,正常的代码查看
      • 使用方式
        可以本地使用
        <script src="jquery/jquery-1.11.3.min.js"></script>
        可以引入网络文件使用
        <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
      • 选择器
        jquery通过选择器就可以找到指定的节点
        id、class、标签、层级
        基本
        :first 第一个
        :last 最后一个
        :even 偶数下标
        :odd 奇数下标
        :eq() 等于哪个下标
        :gt() 大于哪个下标
        :lt() 小于哪个下标

    相关文章

      网友评论

          本文标题:day9_JavaScript+JQuery

          本文链接:https://www.haomeiwen.com/subject/bewmiftx.html