Skip to content Skip to sidebar Skip to footer

Closest In Jquery Not Working

I try to click on .dropzone class through jQuery when users click on .dropzone-upload-btn element. I have this code but it is not doing anything. Any idea why?
).on("click", function() { return $(this).siblings('.dropzone').click(); });

References:

Of course, if you're 100% sure the .dropzone element will come immediately before the .dropzone-upload-btn element, then you can use prev or prevAll:

$('.dropzone-upload-btn').on("click", function() {
    return $(this).prev('.dropzone').click();
});

References:

prevAll can be used if you know the target element will come before the matched one, but not necessarily immediately before. prev will only look at the firstimmediate previous sibling.

The difference between prevAll and siblings is that siblings looks at siblings before and after the matched element, while prevAll looks only at the siblings before it.

Post a Comment for "Closest In Jquery Not Working"