Home:ALL Converter>If object with class X also has class Y then do

If object with class X also has class Y then do

Ask Time:2021-09-22T05:52:44         Author:Thom Watson

Json Formatter

Trying to perform action when <figure> with class .woocommerce-product-gallery__wrapper has another class alongside it - .test.

This .test class is placed there by another JavaScript powered button that's toggling the class in and out. So this event would need to continue listening.

if($( ".woocommerce-product-gallery__wrapper" ).hasClass( "test" )){
console.log('Hello');
// I have the 'hidden' class
};

I feel this is something super easy and as a JS noob, I'm doing something super stupid/missing something.

Author:Thom Watson,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69275935/if-object-with-class-x-also-has-class-y-then-do
Rateb Habbab :

Try:\nif(document.querySelector('.woocommerce-product-gallery__wrapper').classList.contains('test')){\n console.log('Hello');\n};\n",
2021-09-21T21:55:06
yy