将html元素传递到JS库的方法中

时间:2018-07-20 11:40:10

标签: javascript html

调用方法:

document.getElementById("login_form").initLoginForm();

通过“ _myLibraryObject.initLoginForm”方法获取login_form的对象:

(function(window){
    function myLibrary(){
        var _myLibraryObject = {};

        _myLibraryObject.initLoginForm = function(){
            alert(this); //get loginform object here
        };

        return _myLibraryObject;
    }

    if(typeof(window.myLib) === 'undefined'){
        window.myLib = myLibrary();
    }
})(window);

0 个答案:

没有答案
相关问题