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 ...
随机推荐
- 【leetcode】Spiral Matrix II (middle)
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For ...
- 【processing】小代码5
3D void setup() { size(,,P3D); } void draw() { background(); lights(); noStroke(); translate(,,-); r ...
- C 替换字符方法--1
#include "stdafx.h" //linux 底下要去掉这一行 #include <stdio.h> #include<stdlib.h> #in ...
- hdu1492(约数个数定理)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1492 这里先讲一下约数个数定理: 对于正整数x,将其质因分解为 x = pow(p1, a) * po ...
- NYOJ题目596谁是最好的Coder
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAscAAAMaCAIAAADlQ3w8AAAgAElEQVR4nO3dO3LbvN4H4G8T7r2Q1F
- AFNetworking请求设置请求头
NSString *url = @"INPUT URL HERE"; AFHTTPRequestOperationManager *manager = [AFHTTPRequest ...
- ViewPager部分源码分析三:scroll
手指在屏幕上滑动,触发到onTouchEvent(),执行case MotionEvent.ACTION_MOVE: ... public boolean onTouchEvent(MotionEve ...
- MySQL 监控
•Table_locks_immediate The number of times that a request for a table lock could be granted immedia ...
- git 使用技巧
让git不检测文件权限 在android根目录执行:repo forall -c git config core.filemode false即可 修改默认编辑器: git config –globa ...
- Linux(CentOS)常用操作指令(一)
基本指令集合 1.查看CentOS版本信息 cat /proc/version cat /etc/redhat-release 2.查看安全日志文件信息 tail -f /var/log/secure ...