本教程操作环境:windows10系统、jquery3.2.1版本、dell g3电脑。
jquery怎么去掉a标签在jquery中想要去掉a标签,可以利用remove()方法
remove() 方法移除被选元素,包括所有的文本和子节点。
该方法也会移除被选元素的数据和事件。
语法为:
$(selector).remove()
示例如下:
<html><head><meta charset="utf-8"><title>123</title><script src="js/jquery.min.js"></script><script>$(document).ready(function(){$("button").click(function(){$("a").remove();});});</script></head><body> <a href="">a标签1</a> <a href="">a标签2</a><button>移除所有a标签</button></body></html>
输出结果:
相关视频教程推荐:jquery视频教程
以上就是jquery怎么去掉a标签的详细内容。
