So I\'m trying to make each list-item on my site clickable but I\'m not sure what is the best way to do it. Please help me out.
So here is the relevant HTML:
The key is to give the anchor links a display property of "block" and a width property of 100%.
Making list-items clickable (example):
HTML:
<ul>
<li><a href="">link1</a></li>
<li><a href="">link2</a></li>
<li><a href="">link3</a></li>
</ul>
CSS:
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
ul li a {
display: block;
width: 100%;
text-decoration: none;
padding: 5px;
}
ul li a:hover {
background-color: #ccc;
}
Here is a working solution - http://jsfiddle.net/STTaf/
I used simple jQuery:
$(function() {
$('li').css('cursor', 'pointer')
.click(function() {
window.location = $('a', this).attr('href');
return false;
});
});