Set href attribute at runtime using jquery.

<!DOCTYPE html>

<html>

<head>

         <title></title>

         <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

</head>

<body>

        

<a>click me</a>

<script type="text/javascript">

         $("a").click(function()

         {

                  $("a").attr("href","https://www.google.com");

         })

 

 

</script>

</body>

</html>


Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post