How to remove underline from link using JavaScript ?
Given a link and the task is to remove the underline from the anchor element with the help of JavaScript. There are two approaches that are discussed below:
Approach 1: Use textDecoration property of JavaScript to perform this operation. It can be set to many values but, in this example it has been set to none.
- Example:
<!DOCTYPE HTML><html><head><title>How to remove underline fromlink using JavaScript?</title></head><bodystyle="text-align:center;"><h1style="color:green;">GeeksForGeeks</h1><pid="GFG_UP"></p><aid="link"href="#">This is Link</a><br><br><buttononclick="GFG_Fun()">Click Here</button><pid="GFG_DOWN"></p><script>var el_up = document.getElementById('GFG_UP');var el_down = document.getElementById('GFG_DOWN');el_up.innerHTML = "Click on the button to "+ "perform the operation";function GFG_Fun() {var el = document.getElementById('link');el.style.textDecoration = "none";el_down.innerHTML = "Underline Removed";}</script></body></html> - Output:

Approach 2: Use textDecoration property of JavaScript to perform the operation. But, in this example we are setting the value to line-through.
- Example:
<!DOCTYPE HTML><html><head><title>How to remove underline fromlink using JavaScript?</title></head><bodystyle="text-align:center;"><h1style="color:green;">GeeksForGeeks</h1><pid="GFG_UP"></p><aid="link"href="#">This is Link</a><br><br><buttononclick="GFG_Fun()">Click Here</button><pid="GFG_DOWN"></p><script>var el_up = document.getElementById('GFG_UP');var el_down = document.getElementById('GFG_DOWN');el_up.innerHTML = "Click on the button to "+ "perform the operation";function GFG_Fun() {var el = document.getElementById('link');el.style.textDecoration = "line-through";el_down.innerHTML = "Underline Removed";}</script></body></html> - Output:



