Return to Snippet

Revision: 19367
at October 22, 2009 09:28 by stancox


Initial Code
<!-- HTML -->
<ul>
	<li><a href="home">home</a></li>
	<li><a href="home">about</a></li>
	<li><a href="home">contact</a></li>
</ul>

//JavaScript
<script type="text/javascript">
$(document).ready(function(){
 $("ul li").click(function(){  
   //get the url from href attribute and launch the url  
   window.location=$(this).find("a").attr("href"); return false;  
 }); 
});
</script>

Initial URL
http://www.queness.com/post/126/useful-and-handy-jquery-tips-and-tricks

Initial Description
This trick is very useful when you're using UL list to make a menu. What it does is, when you click on the LI area (outside of the link), it will search for the url in the anchor tag and execute the link:

Initial Title
Make the entire LI clickable

Initial Tags


Initial Language
jQuery