4. Make the entire LI clickable
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:
- $("ul li").click(function(){
-
- window.location=$(this).find("a").attr("href"); return false;
- });
$("ul li").click(function(){
//get the url from href attribute and launch the url
window.location=$(this).find("a").attr("href"); return false;
});
- <ul>
- <li><a href="home">home</a></li>
- <li><a href="home">about</a></li>
- <li><a href="home">contact</a></li>
- </ul>