getElementByIdx_x js自定义getElementById函数

2022-01-13,,,

最近看JS代码,发现不少人问getElementByIdx_x是什么函数,其实就是个getElementById自定义函数

函数代码:
复制代码 代码如下:
document.getElementByIdx_x=function(id){
if(typeof id =='string')
return document.getElementById(id);
else
throw new error('please pass a string as a id!')
}

实例代码:
复制代码 代码如下:
9

以上就是getElementByIdx_x js自定义getElementById函数的详细内容,更多请关注本站其它相关文章!

《getElementByIdx_x js自定义getElementById函数.doc》

下载本文的Word格式文档,以方便收藏与打印。