Skip to content

Instantly share code, notes, and snippets.

@arvindang
Created October 21, 2013 16:44
Show Gist options
  • Save arvindang/7086948 to your computer and use it in GitHub Desktop.
Save arvindang/7086948 to your computer and use it in GitHub Desktop.
Use jQuery to change link copy and URL on hover.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-git2.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<a href="http://google.com">Google</a>
</body>
</html>
$('a').hover(function () {
var onText = $(this).text();
onText = "Yahoo";
$('a').text(onText);
var atag = $('a');
atag.attr("href", "http://yahoo.com");
},
function () {
var offText = $(this).text();
offText = "Google";
$('a').text(offText);
var atag = $('a');
atag.attr("href", "http://google.com");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment