如何在console控制台导入jquery

有些网站是没有使用jquery的,在控制台操作dom时有些不方便,可以用一下代码将jquery导入页面。

var importJs=document.createElement('script')//在页面新建一个script标签
importJs.setAttribute("type","text/javascript")//给script标签增加type属性
importJs.setAttribute("src", 'https://ajax.microsoft.com/ajax/jquery/jquery-1.4.min.js') //给script标签增加src属性, url地址为cdn公共库里的
document.getElementsByTagName("head")[0].appendChild(importJs)把importJs标签添加在页面

猜你喜欢

转载自blog.csdn.net/weixin_41395648/article/details/82350650
今日推荐