Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

89
Views
Check the exact div is clicked when a click triggered jQuery
<div class="menu-options-label">Delete group</div>

Want to check the $(document).click() is this div click, If anywhere else is clicked alert('clicked somewhere else').Please guys appreciate your help thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To achieve this add the event handler to the document and interrogate the target property of the event that's passed to the handler to determine which element raised the event.

$(document).on('click', e => {
  let clickedElement = e.target;
  if ($(clickedElement).is('.menu-options-label')) {
    console.log('clicked element');
  } else {
    console.log('clicked somewhere else');
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<div class="menu-options-label">Delete group</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!