I have a PHP search script that parses results into HTML div elements to make styling the results easier. I have the following code:
<div class='webresult'><div class='title'><a href='{$row['url']}'>{$row['title']}</a></div><div class='url'>{$row['url']}</div><div class='desc'>{$row['description']}</div></div>
I want to make it so when a the whole webresult div is clicked on, it goes to the url of the result.
I hope people can understand what I'm trying to describe.
If you want to make the entire div clickable, try to style the <a>
element as a block element and make its size equivalent to the parent <div>
, i.e.,
.title a {
display: block;
width: 100%;
height: 100%;
}
use jQuery:
$('.webresult').click(function() {
window.location.href = $(this).find('a').attr('href');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With