gpt4 book ai didi

javascript - 使用 JavaScript/jQuery 获取以特定前缀开头的所有类名

转载 作者:行者123 更新时间:2023-11-28 04:34:30 37 4
gpt4 key购买 nike

我想根据“category-lifestyle”“category-magazine”等特定前缀提取类。

HTML 标记如下所示:

<article id="post-361" class="et_pb_post post-361 post type-post status-publish format-standard has-post-thumbnail hentry category-lifestyle category-magazine">

Post content...

</article>

最佳答案

您可以使用以下选择器:

console.log(
document.querySelectorAll("article[class*='category-lifestyle']")[0].innerHTML
);

关于javascript - 使用 JavaScript/jQuery 获取以特定前缀开头的所有类名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44352686/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com