jQuery-单击时动态删除head元素 [英] jQuery - dynamically remove head elements on click

查看:102
本文介绍了jQuery-单击时动态删除head元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道您是否可以删除按钮单击上的头部元素,以及如何使用jQuery来完成此操作?

Does anyone know if you can remove head elements on a button click and how to do it with jQuery?

单击按钮时,我试图摆脱html头中的某些脚本标签. 例如.我有1个屏幕视图,并有一个由外部javascript文件控制的幻灯片播放.当我单击按钮单击以摆脱此元素JS"时,我想从HTML Head中删除外部javascript路径.

I am trying to get rid of certain script tags from the html head when a button is clicked. For instance. I have 1 screen view with a slideshow controlled by an external javascript file. When I click on a button "Click to get rid of this elements JS" I want to remove the external javascript path from the HTML Head.

任何想法.已经在这个东西上呆了一个星期左右.

Any ideas. Have been at this thing for a week or so.

推荐答案

您可以向脚本元素添加ID,然后删除该ID:

You can add an id to a script element then remove that ID:

<script type="text/javascript" src="init.js" id="initJs" ></script>

<span id="removeScript"></span>

$('#removeScript').click(function() {
     $('#initJs').remove();
});

这篇关于jQuery-单击时动态删除head元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆