aboutsummaryrefslogtreecommitdiff
path: root/js/lib/NJUtils.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/NJUtils.js')
-rwxr-xr-xjs/lib/NJUtils.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js
index e16715a4..fe8623a1 100755
--- a/js/lib/NJUtils.js
+++ b/js/lib/NJUtils.js
@@ -19,16 +19,18 @@ exports.NJUtils = Object.create(Object.prototype, {
19 19
20 ///// Quick "getElementById" 20 ///// Quick "getElementById"
21 $ : { 21 $ : {
22 value: function(id) { 22 value: function(id, doc) {
23 return document.getElementById(id); 23 doc = doc || document;
24 return doc.getElementById(id);
24 } 25 }
25 }, 26 },
26 27
27 ///// Quick "getElementsByClassName" which also returns as an Array 28 ///// Quick "getElementsByClassName" which also returns as an Array
28 ///// Can return as NodeList by passing true as second argument 29 ///// Can return as NodeList by passing true as second argument
29 $$ : { 30 $$ : {
30 value: function(className, asNodeList) { 31 value: function(className, asNodeList, doc) {
31 var list = document.getElementsByClassName(className); 32 doc = doc || document;
33 var list = doc.getElementsByClassName(className);
32 return (asNodeList) ? list : this.toArray(list); 34 return (asNodeList) ? list : this.toArray(list);
33 } 35 }
34 }, 36 },