To select elements with 'role=article' and filter out elements with 'class=kk-utility-details', you can use the 'closest()' method in combination with the ':not()' selector.

Here's an example using jQuery:

$('*[role='article']').closest(':not(.kk-utility-details)');

This code will select all elements with 'role=article' and exclude elements with 'class=kk-utility-details'.

If you're using plain JavaScript, you can achieve the same result using 'querySelectorAll()' and ':not()' selector:

document.querySelectorAll('[role='article']:not(.kk-utility-details)');

This code will select all elements with 'role=article' and exclude elements with 'class=kk-utility-details'.

How to Select Elements with role='article' and Exclude 'kk-utility-details' Class Using closest() and :not()

原文地址: https://www.cveoy.top/t/topic/qhF8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录