# Triggering a link if wrapped in an \<em\> tag

**URL:** <https://forum.kirupa.com/t/triggering-a-link-if-wrapped-in-an-em-tag/640744>\
**Category:** Uncategorized\
**Created:** [October 6, 2019, 10:02pm UTC](https://forum.kirupa.com/t/triggering-a-link-if-wrapped-in-an-em-tag/640744 "2019-10-06T22:02:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![4a0g1kfa54](https://avatars.discourse-cdn.com/v4/letter/4/5daacb/32.png) [@4a0g1kfa54](https://forum.kirupa.com/u/4a0g1kfa54)\
**Post date:** [October 6, 2019, 10:02pm UTC](https://forum.kirupa.com/t/triggering-a-link-if-wrapped-in-an-em-tag/640744/1 "2019-10-06T22:02:55Z")

</div>

I am having an issue where a modal isn’t triggering if it is wrapped in an _tag.  
In my example, if you click in the “normal” font-style part of the link, it fires properly, if you click where the italics are, it won’t._

 

_Any ideas?_

 

_JS_

 

_> ```
> $(function () {
> const openModals = [];
> $('.modal-button').click(e => {
> e.preventDefault();
> $(e.target).closest('.modal').add('body').addClass('open');
> openModals.push($($(e.target).attr('href')).show());
> });
> $(window).add('.close').click(e => {
> e.stopPropagation();
> if ($(e.target).is('.modal, .close')) {
> const closing = openModals.pop().addClass('modal-content-active');
> setTimeout(() => {closing.hide().removeClass('modal-content-active')}, 0);
> if (openModals.length > 0) {
> openModals[openModals.length - 1].removeClass('open');
> } else $('body').removeClass('open');
> }
> });
> });
> 
> ```_

 

_[FIDDLE](https://jsfiddle.net/postcolonialboy/h70bkej9/30/)_

---

<div class="post-metadata">

**Author:** ![4a0g1kfa54](https://avatars.discourse-cdn.com/v4/letter/4/5daacb/32.png) [@4a0g1kfa54](https://forum.kirupa.com/u/4a0g1kfa54)\
**Post date:** [October 6, 2019, 10:34pm UTC](https://forum.kirupa.com/t/triggering-a-link-if-wrapped-in-an-em-tag/640744/2 "2019-10-06T22:34:20Z")

</div>

by changing `e.target` to `e.currentTarget` , it worked.

```auto
  $('.modal-button').click(e => {
    e.preventDefault();
    $(e.currentTarget).closest('.modal').add('body').addClass('open');
    openModals.push($($(e.currentTarget).attr('href')).show());
  });

```
