{"ScriptPreparationCode":"function getElement(selector, single, pos) {\r\n var el;\r\n\r\n // return single node\r\n // only runs if [single] is undefined\r\n if(single == undefined) el = document.getElementById(selector) || document.querySelector(selector);\r\n\r\n if(el == null) {\r\n if(single == false) {\r\n // return nodelist\r\n el = document.getElementsByClassName(selector);\r\n if(el.length == 0) el = document.getElementsByTagName(selector);\r\n if(el.length == 0) el = document.querySelectorAll(selector);\r\n if(el.length == 0) el = getElementsByClassName(selector);\r\n } else {\r\n // return single node from nodelist\r\n pos = (pos == null) ? 0 : pos; // if arrayPos null, default to 0\r\n\r\n el = document.getElementsByClassName(selector)[pos] ||\r\n document.getElementsByTagName(selector)[pos] ||\r\n document.querySelectorAll(selector)[pos] ||\r\n getElementsByClassName(selector)[pos];\r\n }\r\n }\r\n\r\n return el;\r\n}","TestCases":[{"Name":"vanilla js","Code":"var el = document.getElementsByClassName(\u0027myDiv\u0027)[0];\r\nvar classname = el.className;","IsDeferred":false},{"Name":"jquery","Code":"var el = $(\u0027.myDiv\u0027)[0];\r\nvar classname = el.className;","IsDeferred":false},{"Name":"custom","Code":"var el = getElement(\u0027myDiv\u0027);\r\nvar classname = el.className;","IsDeferred":false}]}