Resolve the problem that the custom $of id method conflicts with the jquery selector $
- 2020-03-30 03:21:28
- OfStack
Change your function name:
Save trouble is also simple, direct batch replacement can be.
Code first:
var $= function (id) {
return "string" == typeof id ? document.getElementById(id) : id;
};
This code is modeled after the jquery custom id selector method, but since the jquery selector also USES this "$", if you refer to jquery and use this method, the page will report an error.
ar getId = function (id) {
return "string" == typeof id ? document.getElementById(id) : id;
};