removeAttr()
methodsYou can use the jQuery removeAttr()
method to remove the attributes from an HTML element.
In the following example when you click the "Remove Link" button it will remove the href
attribute from the link. Let's try it out and see how this method works:
<!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-1.12.4.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>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on harsukh21@gmail.com
Laravel Livewire CRUD Tutorial
Hello Artisan Today i am coming with...How to animate a div height based on the content using jQuery
Use the jQuery animate() metho...Angular 9 - CRUD Example with PHP and MySql
In this tutorial, you'll learn to en...How to customize file input type box using CSS and jQuery
Use the CSS Opacity and Positioning meth...Django 3 CRUD Tutorial Example with MySQL and Bootstrap
Django 3 is released with full async sup...