How to change anchor element URL dynamically?
The HTML <a> element (or anchor element) creates a hyperlink to other web pages, files, locations within the same page, email addresses, or any other URL.
Change anchor element (<a>) href url dynamically by using jquery.
Demo
Change anchor element (<a>) href url dynamically by using jquery.
<script>Final code and demo is here
$(document).ready(function()
{
$("p").text("Anchor element url = "+$("a").attr("href"));
$("button").click(function()
{
$("a").attr("href","http://www.webspeckle.com");
$("p").text("Anchor element url = "+$("a").attr("href"));
});
});
</script>
Demo
Comments
Post a Comment
Ask me anything here...