Last active
June 24, 2016 10:29
-
-
Save bbrochier/42973a2ef9c5b9a023142fdc8bf269b0 to your computer and use it in GitHub Desktop.
Click on the parent trigger the link inside
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.js-link-trigger { | |
cursor: pointer; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="js-link-trigger"> | |
<p>bla bla <a href="#_" class="js-link-target">seo seo seo</a> bla bla bla</p> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('body').on('click', '.js-link-trigger', function(e){ | |
var target = e.target; | |
if (!$(target).hasClass('js-link-target') && $(target).parents('.js-link-target').length === 0) { | |
//if we don't click on the link itself, trigger it | |
$(this).find('.js-link-target').triggerHandler('click'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment