Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
1.2.5
Browse files Browse the repository at this point in the history
新增attr()
  • Loading branch information
ljm12914 committed Mar 13, 2022
1 parent 0caf163 commit 2c1a22a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
29 changes: 21 additions & 8 deletions luery.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ console.log("luery.js ©LJM12914\r\nhttps://github.com/ljm12914/luery\r\nYou are
(_=>{
window.luery = luery;
eval("window." + (window.lueryShortCut || "$") + " = luery;");
function luery(s){return new luery.prototype.processInput(s);}
function luery(s){return new luery.prototype.I(s);}
luery.p = luery.prototype = {
constructor:luery,
processInput:function(s){
I:function(s){
if(!s) luery.E();
else if(typeof s == "string"){
let a = document.querySelectorAll(s);
Expand All @@ -31,6 +31,11 @@ console.log("luery.js ©LJM12914\r\nhttps://github.com/ljm12914/luery\r\nYou are
if(!((o + "").indexOf("NodeList") + 1)) o.addEventListener(e,f);
else if(!((o + "").indexOf("Element") + 1)) for(let i = 0; i < o.length; i++) o[i].addEventListener(e,f);
},
dEvents:(o,e,f)=>{
if(o.length == 0) luery.E();
if(!((o + "").indexOf("NodeList") + 1)) o.removeEventListener(e,f);
else if(!((o + "").indexOf("Element") + 1)) for(let i = 0; i < o.length; i++) o[i].removeEventListener(e,f);
},
//判断JSON文本
isJSONText:s=>{
if(typeof s == "string"){
Expand Down Expand Up @@ -116,13 +121,17 @@ console.log("luery.js ©LJM12914\r\nhttps://github.com/ljm12914/luery\r\nYou are
function f(){
var t = o.offsetTop, l = o.offsetLeft, c = o.offsetParent;
while(c !== null){
//console.log(c.offsetParent);
t += c.offsetTop;
l += c.offsetLeft;
c = c.offsetParent;
}
return {t:t,l:l};
}
function d(a){return parseFloat(o.css(a).replace("px",""));}
},
dom:(o,t)=>{

}
});
})();
Expand Down Expand Up @@ -156,12 +165,8 @@ console.log("luery.js ©LJM12914\r\nhttps://github.com/ljm12914/luery\r\nYou are
this.css("display","");
return this;
}
g.setAttribute=function(k,v){
for(let i = 0; i < this.length; i++) this[i].setAttribute(k,v);
return this;
}
g.removeAttribute=function(k){
for(let i = 0; i < this.length; i++) this[i].removeAttribute(k);
g.attr=function(k,v){
for(let i = 0; i < this.length; i++) this[i].attr(k,v);
return this;
}
}
Expand Down Expand Up @@ -227,6 +232,14 @@ console.log("luery.js ©LJM12914\r\nhttps://github.com/ljm12914/luery\r\nYou are
}
return null;
}
v.attr=h.attr=function(k,v){
if(v === undefined) return this.getAttribute(k);
else{
if(v === null) this.removeAttribute(k);
else this.setAttribute(k,v);
return this;
}
}
}
else lueryFail();
})();
2 changes: 1 addition & 1 deletion luery.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2c1a22a

Please sign in to comment.