Last active
January 1, 2016 22:49
-
-
Save estabij/8212352 to your computer and use it in GitHub Desktop.
Add some styling, add target="_blank" (open link in a new window) and :hover functionality to a set of links in an unordered list using jQuery.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>jquery test</title> | |
<script type="text/javascript" src="js/jquery-2.0.3.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
$('ul li a').each(function() { | |
$(this).css('color', 'black').css('text-decoration', 'none'); | |
$(this).attr("target", "_blank"); | |
$(this).hover(function() { | |
$(this).css('text-decoration', 'underline'); | |
}, function() { | |
$(this).css('text-decoration', 'none'); | |
}); | |
}); | |
}); | |
</script> | |
</head> | |
<body id="home"> | |
<ul id="ulMainNav"> | |
<li><a href="index.html">Home</a></li> | |
<li><a href="admin.html">Admin</a></li> | |
<li><a href="tools.html">Tools</a></li> | |
<li><a href="contact.html">Contact</a></li> | |
</ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment