Tag Archives: div clickable

How To Make The Whole Div Clickable with CSS Only

HTML Example:   <div id="myDiv"> <a href="http://blog.fabriziomichels.com"  class="clickDiv">view website</a> </div>   CSS   div#myDiv { width:300px; height:250px; background:url(../images/any_background_image.jpg) no-repeat; float:left; margin:0; padding:0; }   .clickDiv { display:block; height:50px; text-align:center; padding:200px 0 ; }  
Posted in CSS | Also tagged , , | Leave a comment

How to make the entire div clickable

First, find a link inside div class “myDiv”, then redirects to the link when anywhere in div is clicked. jQuery   $(".myDiv").click(function(){      window.location=$(this).find("a").attr("href");      return false; });   HTML Example   <div class="myDiv">      <p>Loren Ipsun dolor dummy text.</p>     <a href="http://www.fabriziomichels.com">My Site</a> </div>  
Posted in jQuery | Also tagged , | Leave a comment