gpt4 book ai didi

javascript - 如何在内部 html 中获取特定类

转载 作者:行者123 更新时间:2023-11-28 03:30:36 24 4
gpt4 key购买 nike

我正在尝试访问特定的类名并在另一个类中单击它。我会怎么做?

例如,

var keyword = "blah";
//Add elements with this specific class name to array
for(var i = 0; i < 20; i++)
array[i] = documents.getElementsByClassName(specific string)[i].innerHTML

//Once a specific element in the array has a matching keyword get specific class name of that element and click on it
for(var j = 0; j < 20; j++)
if(array[j].match(keyword) == keyword){
//Get class name within the innerhtml and click on it

最佳答案

正如 J L 所说,目前最简单的方法是使用 jQuery .click() 和适当的定位器。查看:http://api.jquery.com/class-selector/

您可能还想使用 containscontents特点

关于javascript - 如何在内部 html 中获取特定类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18089738/

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