I need to catch the event when a user clicks a hyperlink outside of a specific div
element. To demonstrate :
If I have this HTML :
<a id = "1" href="/someurl..">link</a>
<a id = "2" href="/someurl..">link</a>
<a id = "3" href="/someurl..">link</a>
<div id="content">
<a id = "4" href="/someurl..">link</a>
</div>
I need to catch the event where the user clicks every hyperlink outside of the div
with id
of "content". But ignore the event when the links inside the div
"content" is clicked.
------------------UPDATE----------------
Someone suggested I include what i'm trying to achieve to add clarity. And what the best way to do this is the question.
My use case is that, I have a div where some operations (links) such as sort, edit etc is being utilized. While links outside are links that redirects to other pages. I want to make a confirm modal using bootbox if a user navigates away. I could use the unload but it also fires when I click on the edit,sort operations (links inside the div).
Thanks!