争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

zepto是什么

时间:2024/4/29作者:未知来源:争怎路由网人气:

getComputedStyle(this[0], '').getPropertyValue(property)) //设置样式 var css = '' if (type(property) == 'string') { if (!value && value !== 0) //当value的值为非零的可以转成false的值时如(null,undefined),删掉property样式 this.each(function() { //style.removeProperty 移除指定的CSS样式名(IE不支持DOM的style方法) this.style.removeProperty(dasherize(property)) }) else css = dasherize(property) + ":" + maybeAddPx(property, value) } else { //当property是对象时 for (key in property) if (!property[key] && property[key] !== 0) //当property[key]的值为非零的可以转成false的值时,删掉key样式 this.each(function() { this.style.removeProperty(dasherize(key)) }) else css += dasherize(key) + ':' + maybeAddPx(key, property[key]) + ';' } //设置 return this.each(function() { this.style.cssText += ';' + css }) }, index: function(element) { //这里的$(element)[0]是为了将字符串转成node,因为this是个包含node的数组 //当不指定element时,取集合中第一条记录在其父节点的位置 //this.parent().children().indexOf(this[0])这句很巧妙,和取第一记录的parent().children().indexOf(this)相同 return element ? this.indexOf($(element)[0]) : this.parent().children().indexOf(this[0]) }, hasClass: function(name) { return emptyArray.some.call(this, function(el) { //注意这里的this是classRE(name)生成的正则 return this.test(className(el)) }, classRE(name)) }, addClass: function(name) { return this.each(function(idx) { classList = [] var cls = className(this), newName = funcArg(this, name, idx, cls) //处理同时多个类的情况,用空格分开 newName.split(/\s+/g).forEach(function(klass) { if (!$(this).hasClass(klass)) classList.push(klass) }, this) classList.length && className(this, cls + (cls ? " " : "") + classList.join(" ")) }) }, removeClass: function(name) { return this.each(function(idx) { if (name === undefined) return className(this, '') classList = className(this) funcArg(this, name, idx, classList).split(/\s+/g).forEach(function(klass) { classList = classList.replace(classRE(klass), " ") }) className(this, classList.trim()) }) }, toggleClass: function(name, when) { return this.each(function(idx) { var $this = $(this), names = funcArg(this, name, idx, className(this)) names.split(/\s+/g).forEach(function(klass) { (when === undefined ? !$this.hasClass(klass) : when) ? $this.addClass(klass) : $this.removeClass(klass) }) }) }, scrollTop: function() { if (!this.length) return return ('scrollTop' in this[0]) ? this[0].scrollTop : this[0].scrollY }, position: function() { if (!this.length) return var elem = this[0], // Get *real* offsetParent offsetParent = this.offsetParent(), // Get correct offsets offset = this.offset(), parentOffset = rootNodeRE.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset() // Subtract element margins // note: when an element has margin: auto the offsetLeft and marginLeft // are the same in Safari causing offset.left to incorrectly be 0 offset.top -= parseFloat($(elem).css('margin-top'))

关键词:zepto是啥




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版