12-jQuery获取相关尺寸
# 相关尺寸
**获取元素相对于文档的偏移量**
> var pos = $('#small').offset();
>
> // console.log(pos.left);// console.log(pos.top);
**获取当前元素相对于父级元素的偏移量**
> var l = $('#small').position().left;
>
> var t = $('#small').position().top;
>
> // console.log(l,t);
**获取文档滚动距离**
> var st = $(document).scrollTop();
>
> var sl = $(document).scrollLeft();
**获取元素的宽度和高度**
> var w = $('#big').width();
>
> var h = $('#big').height();
**设置元素的宽度和高度**
> $('#big').width(400);
>
> $('#big').height(400);
>
> // console.log(w,h);
**获取可视区域的宽度和高度**
> var cw = $(window).width();
>
> var ch = $(window).height();
**获取文档的宽度和高度**
> var cw = $(document).width();
>
> var ch = $(document).height();
>
> console.log(cw,ch);
# 关于事件
## 事件绑定
1.**基本绑定**
> $(element).click(function(){})
>
> $(element).dblclick(function(){})
>
> 。。。
>
> 加载完毕事件
>
> $(document).ready(function(){})
>
> $(function(){})
2.**方法绑定**
> $(element).bind('click', function(){})//绑定事件
>
> $(element).unbind();//解除事件绑定
12-jQuery获取相关尺寸的更多相关文章
- jQuery的相关尺寸获取 - 学习笔记
获取元素相对于文档的偏移量 获取当前元素相对于父级元素的偏移量 获取文档滚动距离 获取元素的宽度和高度 设置元素的宽度和高度 获取可视区域的宽度和高度 获取文档的宽度和高度 获取元素相对于文档的偏移量 ...
- [Web 前端] 027 jQuery 相关尺寸与事件绑定
1. 相关尺寸 1.1 获取元素相对于文档的偏移量 var pos = $('#small').offset(); console.log(pos.left, pos.top); 1.2 获取当前元素 ...
- aspx中的表单验证 jquery.validate.js 的使用 以及 jquery.validate相关扩展验证(Jquery表单提交验证插件)
这一期我们先讲在aspx中使用 jquery.validate插件进行表单的验证, 关于MVC中使用 validate我们在下一期中再讲 上面是效果,下面来说使用步骤 jQuery.Valid ...
- jQuery获取Radio选择的Value值||两个select之间option的互相添加操作(jquery实现)
jQuery获取Radio选择的Value值: 1. $("input[name='radio_name'][checked]").val(); //选择被选中Radio的Val ...
- jquery 获取css position的值
jquery 获取css position的值 CreateTime--2018年5月28日14:03:12 Author:Marydon 1.情景展示 <div id="aa&q ...
- Jquery获取select option动态添加自定义属性值失效
Jquery获取select option动态添加自定义属性值失效 2014/12/31 11:49:19 中国学网转载 编辑:李强 http://www.xue163.com/588880/3909 ...
- js/jquery获取文本框的值与改变文本框的值
我们就用它来学习获取文本框的值及改变文本框的值. 代码如下 复制代码 <script>function get1(){ document.getElementById("txtb ...
- jQuery获取多种input值的方法
1 if($("input[name=item][value='val']").attr('checked')==true) //判断是否已经打勾 name即控件name属性,va ...
- jquery 获取设置值、添加元素详解
jQuery 获取内容和属性 jQuery DOM 操作 jQuery 中非常重要的部分,就是操作 DOM 的能力. jQuery 提供一系列与 DOM 相关的方法,这使访问和操作元素和属性变得很容易 ...
随机推荐
- Leetcode 4. Median of Two Sorted Arrays(中位数+二分答案+递归)
4. Median of Two Sorted Arrays Hard There are two sorted arrays nums1 and nums2 of size m and n resp ...
- (26)Python获取某个文件存放的相对路径(更改任意目录下保持不变)
import os import platform def getSeparator(): ''' 获取不同平台下的斜杠符号 :return: Created by Wu Yongcong 2017- ...
- 解决:@Auarowired为null
使用@Auarowired时程序报空指针.如图: 将private 更改为 public 即可
- 利用python进行数据分析--pandas入门1
随书练习,第五章 pandas入门1 # coding: utf-8 # In[1]: from pandas import Series, DataFrame # In[2]: import pa ...
- Mybatis传多个参数(三种解决方案) mapper.xml的sql语句修改!
第一种 Public User selectUser(String name,String area); 对应的Mapper.xml <select id="selectUser&qu ...
- c# access oledb helper class
连接Access数据库 using System; using System.Collections.Generic; using System.Linq; using System.Text; us ...
- 用vuex实现购物车功能
效果图 展示目录结构 product组件(纯静态代码) cart组件(纯静态代码) info组件(纯静态代码) 完成以上的三个组件,现在要开始调用这些组件,在App.vue中调用 如果你的姿势正确的话 ...
- Git 实践
最近也学习了Git的相关知识,现通过一个实例来记录Git使用流程,也方便日后使用. git的基础学习: https://www.yiibai.com/git/git-quick-start.html ...
- Tensorflow | 基本函数介绍 简单详细的教程。 有用, 很棒
http://blog.csdn.net/xxzhangx/article/details/54606040 Tensorflow | 基本函数介绍 2017-01-18 23:04 1404人阅读 ...
- 【ABAP系列】SAP ABAP 仓库库存-物料拆分的算法
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 仓库库存-物料 ...