Hi guys.
I use this code snippet when I want to make make a div a selectable hyperlink.
$('myDiv').click(function(){
window.location = $('this').attr("mylink.html") ;
});
It is simple and it works.
But repeating it seems wasteful.
Lets say I have a navigation menu that consists of an ordered list containing a group of list elements. This is a very common design pattern for navigation. Lets say that I want each list item to contain a div, and I want each div to be clickable.
Yes, I know there is a usability issue there: relying on js to create hyperlinks is an ugly sin. But its easy enough to put an anchor element inside the "link div" for user agents without javascript. So here is our html:
<ol>