VQuery选择器
VQUery
elements属性,储存选中的元素
参数
typeof的作用
字符串
class ID tagName
函数
事件绑定
对象
直接插入
$函数
绑定事件
click方法
显示隐藏,--show,hide方法
hover方法
解决函数中的this问题
call aplly
toggle方法
点击计数
arguments的使用
样式与属性
css方法
简单形式----设置,获取
获取计算后的样式
attr方法
jquery.js地址 http://pan.baidu.com/s/1pLjEBCR
获取和查找
eq方法
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
div {width:100px; height:100px; background:red; float:left; margin:10px;}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jquery-1.7.1.js"></script>
<script>
$(function (){
$('div').eq(1).css('background', 'green');
});
</script>
</head> <body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>
eq使用
find方法
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="VQuery.js"></script>
<script>
$(function (){
$('ul').find('.box').css('background', 'red');
});
</script>
</head> <body>
<ul id="ul1">
<li></li>
<li></li>
<li></li>
</ul>
<ul>
<li class="box"></li>
<li class="box"></li>
<li></li>
</ul>
<ol>
<li></li>
<li></li>
<li></li>
</ol>
</body>
</html>
find的使用
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
#div1 {width:100px; height:100px; background:red;}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="VQuery.js"></script>
<script>
$(function (){
$('#btn1').click(function (){
$('#div1').show();
}); $('#btn2').click(function (){
$('#div1').hide();
});
});
</script>
</head> <body>
<input id="btn1" type="button" value="显示" />
<input id="btn2" type="button" value="隐藏" />
<div id="div1">
</div>
</body>
</html>
显示隐藏
index方法
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jquery-1.7.1.js">
</script>
<script>
$(function(){
$('input').click(function(){
alert($(this).index());
});
})
</script>
</head> <body><input type="button" value="aaa" />
<input type="button" value="bb" />
<input type="button" value="ccc" />
<input type="button" value="ddd" />
</body>
</html>
index
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
window.onload=function()
{
var aBtn=document.getElementsByTagName('input');
var i=0;
for(i=0; i<aBtn.length; i++)
{
addClick(aBtn[i]);
}
function addClick(obj)
{
var count=0;
obj.onclick=function()
{
alert(count++);
}
}
}
</script>
</head> <body>
<input type="button" value="aaa" />
<input type="button" value="bbb" />
<input type="button" value="ccc" />
<input type="button" value="ddd" />
</body>
</html>
点击计数
VQuery选择器的更多相关文章
- 常见的js函数
改变元素的样式 var changeStyle = function(elem,name,value){ elem.style[name] = value; } 空位补零 fu ...
- 前端极易被误导的css选择器权重计算及css内联样式的妙用技巧
记得大学时候,专业课的网页设计书籍里面讲过css选择器权重的计算:id是100,class是10,html标签是5等等,然后全部加起来的和进行比较... 我只想说:真是误人子弟,害人不浅! 最近,在前 ...
- jQuery的61种选择器
The Write Less , Do More ! jQuery选择器 1. #id : 根据给定的ID匹配一个元素 <p id="myId">这是第一个p标签< ...
- 05.LoT.UI 前后台通用框架分解系列之——漂亮的时间选择器
LOT.UI分解系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#lotui LoT.UI开源地址如下:https://github.com/du ...
- CSS 选择器及各样式引用方式
Css :层叠样式表 (Cascading Style Sheets),定义了如何显示HTML元素. 目录 1. 选择器的分类:介绍ID.class.元素名称.符合.层次.伪类.属性选择器. 2. 样 ...
- jQuery学习之路(1)-选择器
▓▓▓▓▓▓ 大致介绍 终于开始了我的jQuery学习之路!感觉不能再拖了,要边学习原生JavaScript边学习jQuery jQuery是什么? jQuery是一个快速.简洁的JavaScript ...
- 谈谈一些有趣的CSS题目(十)-- 结构性伪类选择器
开本系列,谈谈一些有趣的 CSS 题目,题目类型天马行空,想到什么说什么,不仅为了拓宽一下解决问题的思路,更涉及一些容易忽视的 CSS 细节. 解题不考虑兼容性,题目天马行空,想到什么说什么,如果解题 ...
- JQuery 选择器
选择器是JQuery的根基,在JQuery中,对事件的处理,遍历DOM和AJAX操作都依赖于选择器.如果能够熟练地使用选择器,不仅能简化代码,而且还可以事半功倍. JQuery选择器的优势 1.简洁的 ...
- jq选择器基础
Jquery $代表选择器 使用jq必须要导入jq文件 <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js&qu ...
随机推荐
- Cloudservie将LocalStroage中的内容通过WAD自动上传到BLOB中
开发云服务程序,如果使用Local stroage存储我们临时生成的日志或者文件并将它们自动上传到BLOB中,可以通过WAD来实现,具体如下: 1.配置webrole,开启Local stroage功 ...
- RHEL本地yum源
一.挂载本地镜像做yum源(环境:RHEL6.5 64位 VM11) 1.进入/etc/yum.repos.d目录, [root@localhost yum.repos.d]# ls packagek ...
- 在VS2013中强制IIS Express应用程序池使用经典模式
直接在文件夹地址栏输入 %userprofile%\documents\iisexpress\config\applicationhost.config 会打开上边的配置文件 将 <siteDe ...
- Sqlserver2008 表分区教程
先声明..Sql2008只有企业版才能够搞这个表分区.其他版本请自觉更改.. 哥在这里费了很长时间劲..结果还是老老实实的重装.. 表分区定义 一般情况下,我们建立数据库表时,表数据都存放在一个文件里 ...
- 使用 Ant 自动生成项目构建版本
引言 对 于多版本项目,要提供新版本来跟上新功能或缺陷报告增加的速度,并同时仍然保持可接受的质量水平,可能是一项不小的挑战.构建自动化可确保准确性和消除人 为错误的可能性,从而部分地解决此问题.自动化 ...
- javascript 数据类型转换
javascrīpt 类型转换函数 在Javascrīpt中,Double类型和Int类型都是看作为Number对象. 1.Number转成String number.toString() Strin ...
- jquery音乐播放器(歌词滚动版)
好久没出来水了!!!忙忙碌碌的找工作~然后中秋节也算过了,祝各位coding们,直接觉醒第七感小宇宙,直接用心就能找到bug-_-// 最后如题这是一篇很正规的coding的文章 大概么比以前的加了个 ...
- HTTP报文详解
二.HTTP请求首部字段 1 Accept 2 Accept-Charset 3 Accept-Encoding 4 Accept-Language 5 Authorization 6
- 利用百度语音API进行语音识别。
由于项目需要,这几天都在试图利用百度语音API进行语音识别.但是识别到的都是“啊,哦”什么的,我就哭了. 这里我只是分享一下这个过程,错误感觉出现在Post语音数据那一块,可能是转换问题吧. API请 ...
- POJ 2029 Get Many Persimmon Trees
Get Many Persimmon Trees Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3243 Accepted: 2 ...