mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-22 23:16:53 +00:00
Added class manipulation utilities
This commit is contained in:
parent
581d165822
commit
4c01ae392e
21
js/Utils.js
21
js/Utils.js
@ -238,4 +238,25 @@ utils.domContains = function(a,b) {
|
||||
!!(a.compareDocumentPosition(b) & 16);
|
||||
};
|
||||
|
||||
utils.hasClass = function(el,className) {
|
||||
return el.className.split(" ").indexOf(className) !== -1;
|
||||
}
|
||||
|
||||
utils.addClass = function(el,className) {
|
||||
var c = el.className.split(" ");
|
||||
if(c.indexOf(className) === -1) {
|
||||
c.push(className);
|
||||
}
|
||||
el.className = c.join(" ");
|
||||
}
|
||||
|
||||
utils.removeClass = function(el,className) {
|
||||
var c = el.className.split(" "),
|
||||
p = c.indexOf(className);
|
||||
if(p !== -1) {
|
||||
c.splice(p,1);
|
||||
el.className = c.join(" ");
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user