make a div into a link using jquery
by Francis[ Edit ] 2014-04-26 10:09:36
make a div into a link using jquery
In html:
<div class="classname"> < a href="index.php"> Index </a> </div>
<div class="classname"> < a href="page1.php"> Page 1 </a> </div>
<div class="classname"> < a href="page2.php"> Page 2 </a> </div>
In css :
<style>
.classname
{
border: 3px solid #F3D1B6;
border-radius: 10px 10px 10px 10px;
color: #E8C2AF;
font: bold 11px/20px Tahoma,Geneva,sans-serif;
padding: 0 7px;
}
</style>
In Js:
<script>
$(".classname").click(function()
{
window.location.href = $(this).find('a').attr('href');
});
</script>