no-jquery 01Elements
Select Elements
id
// IE 5.5+
document.getElementById('myElement');
// IE 8+
document.querySelector('#myElement');
class
// IE 9+
document.getElementsByClassName('myElement');
// IE 8+
document.querySelectorAll('.myElement');
Pseudo-class
// IE 8+
document.querySelectorAll('#myForm :invalid');
tagName
// IE 5.5+
document.getElementsByTagName('div');
// IE 8+
document.querySelectorAll('div');
attribute
// IE 8+
document.querySelectorAll('[data-foo-bar="someval"]');
Children
// IE 5.5+
// NOTE: This will include comment and text nodes as well.
document.getElementById('myParent').childNodes;
// IE 9+ (ignores comment & text nodes).
document.getElementById('myParent').children;
// IE 8+
document.querySelector('#myParent > [ng-click]');
Descendants
// IE 8+
document.querySelectorAll('#myParent A');
Excluding Elements
// IE 9+
document.querySelectorAll('DIV:not(.ignore)');
Multiple Selectors
// IE 8+
document.querySelectorAll('DIV, A, SCRIPT');
Pattern
window.$ = function(selector) {
var selectorType = 'querySelectorAll';
if (selector.indexOf('#') === 0) {
selectorType = 'getElementById';
selector = selector.substr(1, selector.length);
}
return document[selectorType](selector);
};
no-jquery 01Elements的更多相关文章
- Angular杂谈系列1-如何在Angular2中使用jQuery及其插件
jQuery,让我们对dom的操作更加便捷.由于其易用性和可扩展性,jQuer也迅速风靡全球,各种插件也是目不暇接. 我相信很多人并不能直接远离jQuery去做前端,因为它太好用了,我们以前做的东西大 ...
- jQuery UI resizable使用注意事项、实时等比例拉伸及你不知道的技巧
这篇文章总结的是我在使用resizable插件的过程中,遇到的问题及变通应用的奇思妙想. 一.resizable使用注意事项 以下是我在jsfiddle上写的测试demo:http://jsfiddl ...
- Jquery的点击事件,三句代码完成全选事件
先来看一下Js和Jquery的点击事件 举两个简单的例子 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&q ...
- jQuery实践-网页版2048小游戏
▓▓▓▓▓▓ 大致介绍 看了一个实现网页版2048小游戏的视频,觉得能做出自己以前喜欢玩的小游戏很有意思便自己动手试了试,真正的验证了这句话-不要以为你以为的就是你以为的,看视频时觉得看懂了,会写了, ...
- jquery和Js的区别和基础操作
jqery的语法和js的语法一样,算是把js升级了一下,这两种语法可以一起使用,只不过是用jqery更加方便 一个页面想要使用jqery的话,先要引入一下jqery包,jqery包从网上下一个就可以, ...
- jQuery之ajax实现篇
jQuery的ajax方法非常好用,这么好的东西,你想拥有一个属于自己的ajax么?接下来,我们来自己做一个简单的ajax吧. 实现功能 由于jq中的ajax方法是用了内置的deferred模块,是P ...
- 利用snowfall.jquery.js实现爱心满屏飞
小颖在上一篇一步一步教你用CSS画爱心中已经分享一种画爱心的方法,这次再分享一种方法用css画爱心,并利用snowfall.jquery.js实现爱心满屏飞的效果. 第一步: 利用伪元素before和 ...
- jQuery的61种选择器
The Write Less , Do More ! jQuery选择器 1. #id : 根据给定的ID匹配一个元素 <p id="myId">这是第一个p标签< ...
- jquery.uploadify文件上传组件
1.jquery.uploadify简介 在ASP.NET中上传的控件有很多,比如.NET自带的FileUpload,以及SWFUpload,Uploadify等等,尤其后面两个控件的用户体验比较好, ...
- 浅谈 jQuery 核心架构设计
jQuery对于大家而言并不陌生,因此关于它是什么以及它的作用,在这里我就不多言了,而本篇文章的目的是想通过对源码简单的分析来讨论 jQuery 的核心架构设计,以及jQuery 是如何利用javas ...
随机推荐
- Android studio 自定义打包APK名称
Android Studio打包应用默认生成的apk名称是:app-release.apk .如果我们要让生成的apk名跟我们版本包名有联系的话,那我们就要自定义生成的apk名了,要怎么做呢. 我们只 ...
- 【leetcode】Reverse Bits(middle)
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- XP/Win7下QTP11循环试用30天的破解方法
XP/Win7下QTP11循环试用30天的破解方法. XP下:1.找到以下路径:C:\Documents and Settings\All Users\Application Data\SafeNet ...
- iOS 本人必装插件
本人觉得比较好用也实用的Xcode插件记录: 1. Alcatraz 插件通过它来管理 : https://github.com/alcatraz/Alcatraz.git 2. Cocoa ...
- September 24th 2016 Week 39th Saturday
The worst solitude is to be destitute of sincere friendship. 最大的孤独莫过于没有真诚的友谊. I walk slowly, but I n ...
- c语言运算符
一.op=形式的赋值操作符 int a=0; a+=1; //等价于 a=a+1;// a*=1; 二.op=类表达式 int a=10,b=5; a/=b;//等价于a=a/b; a*=b+1; ...
- @ifconfig eth0|awk -F "[ :]+" 'NR==2{print $4 "/" $NF}'中"[ :]+" 是什么意思?@
http://blog.csdn.net/zhuying_linux/article/details/6822987
- 记录一个mysql按日期分组统计的查询
http://blog.csdn.net/llwan/article/details/7738991
- DC/DC与LDO的差别
转自:http://bbs.eetop.cn/thread-459121-1-1.html 在平时的学习中,我们都有接触LDO和DC/DC这一类的电源产品,但作为学生的我们队这些东西可能了解不够深刻, ...
- Sexagenary Cycle(天干地支法表示农历年份)
Sexagenary Cycle Time Limit: 2 Seconds Memory Limit: 65536 KB 题目链接:zoj 4669 The Chinese sexagen ...