• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

91
Views
Find element directly above clicked item in dom via jQuery

When an element with the class facetwp-color-label is clicked, I am then trying to use jQuery trigger() on the dom element class="facetwp-color" directly above.

enter image description here

Current code:

$(document).on('click', '.facetwp-color-label', function() {
    $(this).closest('.facetwp-color').trigger('click');
});

I tried with prev(), next(), closest(). None are triggering so far. Here is my manual attempt to confirm .trigger() works on the element I am targeting:

$(document).on('click', '.facetwp-color-label', function() {
    $(this).closest('.facetwp-color').trigger('click');

    console.log(this);
});

Result:

<div class="facetwp-color-label">Cream</div>
about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error