封装document.getElementById(id)

CreateTime--2016年12月18日11:42:45
Author:Marydon
封装document.getElementById(Id)方法

<script type="text/javascript">
    var xyhsoft = new Object();
    xyhsoft.dom = new Object();
    $Get = $get = xyhsoft.dom.GetElement = function(Id) {
        return(typeof(Id) == "string" ? document.getElementById(Id): Id);
    };
</script>
//测试
window.onload = function() {
    console.log($get("aa").value);
}
<input type="text" value="zhangsan" id="aa"/>

UpdateTime--2017年10月31日14:50:38

$get = function(id) {
    return document.getElementById(id);
};
原文地址:https://www.cnblogs.com/Marydon20170307/p/6541298.html