Home >Web Front-end >JS Tutorial >getElementByIdx_x js custom getElementById function_javascript skills

getElementByIdx_x js custom getElementById function_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:56:471846browse

Function code:

Copy code The code is as follows:

document.getElementByIdx_x=function(id){
if(typeof id =='string')
return document.getElementById(id);
else
throw new error('please pass a string as a id!')
}

Example code:
Copy code The code is as follows:

9