Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Change the Value of an Attribute</title> </head> <body> <p><a href="#" id="myLink">Tutorial Republic</a></p> <script> // Selecting the element var link = document.getElementById("myLink"); // Changing the href attribute value link.setAttribute("href", "https://www.appwang.com"); </script> </body> </html>