How to disable anchor tag(<a>) with Javascript using Tag name attribute (so that link return nothing) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to disable anchor tag(<a>) with Javascript using Tag name attribute (so that link return nothing)

25th Jul 2016, 7:16 AM
Shubham Gupta
Shubham Gupta - avatar
2 Answers
+ 1
Following code may help you JavaScript if (condition) { document.getElementsByTagName('a')[0].removeAttribute('href'); } and if you are using jQuery if (condition) { $('a').first().removeAttr('href'); }
25th Jul 2016, 12:20 PM
Ali
Ali - avatar
0
Not possible
25th Jul 2016, 12:19 PM
Ayushya Shah
Ayushya Shah - avatar