Reputation: 1722
I'm looking for a way to make an entire <div>
a link but not the content in it. Say for example I've got four images in a <div>
and if you click anywhere but the images, it will actually be a link. I need it to function that way since I'm using it for a lightbox. Anytime you click anywhere but the images, it will have the attribute <a href="#close">
. I need the ability to scroll through the images from anywhere on the screen, so it's container must remain 100% height and width. I've also found Javascript solutions to make the entire <div>
clickable, but I can't find out how to make it so it can still scroll and exclude the images from the <a>
.
Upvotes: 0
Views: 86
Reputation: 219938
You'll have to resort to JavaScript for that:
document.getElementById('link').addEventListener('click', function (e) {
if ( e.targetElement != this ) e.preventDefault();
});
Upvotes: 1