diff options
Diffstat (limited to 'js/lib/NJUtils.js')
-rwxr-xr-x | js/lib/NJUtils.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 67bb59c4..f6284b6c 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 | }, |