版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/web_zhouliang/article/details/70174214
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>封装jquery的$方法</title> </head> <body> <script> window.$=HTMLElement.prototype.$=function(selector){ return (this==window?document:this).querySelectorAll(selector) } </script> </body> </html>