Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

28
Vistas
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>
7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos