答:使用jQueryremoveAttr()方法
您可以使用jQueryremoveAttr()方法从HTML元素中删除属性。
在下面的示例中,当您单击“删除链接”按钮时,它将href从链接中删除属性。让我们尝试一下,看看这种方法是如何工作的:
例试试这个代码»
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Removing Attribute from HTML Element</title>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
    $(document).ready(function() {
        $(".remove-attr").click(function(){            
            $("a").removeAttr("href");
        });
    });
</script> 
</head>
<body>
    <button type="button" class="remove-attr">Remove Link</button>
    <a href="#">Demo Link</a>
</body>
</html>
	
                    	
                    	
                    	  
                    	    
                    	    
                    	    
                    	 
    如果您觉得本文的内容对您的学习有所帮助:
     
                    	
                    	   
                    	   关键字:
html