I want to remove or disable anchor tag attribute which comes under <div class="removetag"> class from JavaScript without giving specific id to one anchor tag we can use div class for that.
Please help me how to I can do this thing.
My code
<div class="removetag">
<a href="google.com"> google </a>
</div>
<div class="notremove">
<a href="google.com"> google </a>
</div>
I think this is what you need:
document.querySelector('.removetag a').removeAttribute('href')
Since you've tagged the question with jQuery, you can solve your problem this way:
$(".removetag a").removeAttr("href");
Demo
$(".removetag a").removeAttr("href");
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="removetag">
<a href="google.com"> google </a>
</div>
<div class="notremove">
<a href="google.com"> google </a>
</div>
to remove a an attribute you should use removeAttribute('attributeName'): removeAttribute('href')
to select a class use querySelector. However this will only return the first element with this class. To get all elements with this class you need to use querySelectorAll and use forEach to give a command to all of those elements.
var removetag = document.querySelectorAll('.removetag a');
removetag.forEach(el => el.removeAttribute('href'));
<div class="removetag">
<a href="google.com"> google </a>
</div>
<div class="notremove">
<a href="google.com"> google </a>
</div>
<div class="removetag">
<a href="google.com"> google </a>
</div>
<div class="notremove">
<a href="google.com"> google </a>
</div>