I'm trying to get an element by class name and in IE 9+ i can use document.getElementsByClassName while in IE 8 document.querySelectorAll works.
The above 2 functions are not available in IE 7 and i'm trying to use the idea in kapa's answer provided here getElementsByClassName() doesn't work in old Internet Explorers like IE6, IE7, IE8
Below is the code i'm trying `
function getElementsByClassNameBackwardCompatability(className) {
    if (document.getElementsByClassName) {
        return document.getElementsByClassName(className);//EI 9+
    } else if (document.querySelectorAll(className)) {
        return document.querySelectorAll(className);//EI 8
    } else { // IE7 - (not working)
        var d = document, element, pattern;
        pattern = ".//*[contains(concat(' ',@@class, ' '), ' " + className + " ')]";
        element = d.evaluate(pattern, d, null, 0, null);
        return  element;
    }
}`
It throws the error "JavaScript runtime error: Could not complete the operation due to error 80020101." in IE 7
And below is how i'm using the function
     var ddlone = getElementsByClassNameBackwardCompatability(".myClass");
        $(ddlone).dropdownchecklist("destroy");
        $(ddlone).dropdownchecklist({ icon: {}, closeRadioOnClick: true, maxDropHeight: 150});
  $(getElementsByClassNameBackwardCompatability(".myDateClass")).each(function () {
            $(this).datepicker({
                dateFormat: 'dd/mm/yy',
                showButtonPanel: true,
                changeMonth: true,
                changeYear: true,
                defaultDate: new Date(),
            });});
Any one how i can get this working in IE 7?