jQuery被开发者如此的青睐和它强大的选择器有很大关系,比起笨重的document.getElementById.document.getElementByName… ,查找元素很方便,其实W3C中提供了querySelector和querySelectorAll查询接口已经实现了类似功能. 定义 其实这两个方法看名字就能明白什么意思,不过还是引用一下W3C的解释 querySelector:return the first matching Element node within the n…
1. 用web storage替换cookiesCookie最大的问题是每次都会跟在请求后面.在HTML5中,用sessionStorage和localStorage把用户数据直接在客户端,这样可以减少HTTP请求的数据量.而且Web storage还提供了API来操作数据,不像cookie,还得自己写. // if localStorage is present, use that if (('localStorage' in window) && window.localStor…