有谁知道当我单击此 p
时如何从我的 html 页面中删除“js/sample.js”文件标签:
<!DOCTYPE html>
<html>
<head>
<style>
p { color:red; margin:5px; cursor:pointer; }
</style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="js/sample.js"></script>
</head>
<body>
<p>First Paragraph</p>
<p>Second Paragraph</p>
<p>Yet one more Paragraph</p>
<script>
$("p").click(function () {
$(' ').removeattr('src');
});
</script>
</body>
</html>
最佳答案
亲爱的 friend ,请尝试以下代码,它会对您有用
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script id="script1" src="js/sample.js"></script>
<script>
$(function () {
$("p").click(function () {
$('script1').att('src').remove();
});
});
</script>
关于javascript - 单击按钮时如何删除脚本。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16284211/