尝试从 webBrowser c# 更改 class 值

Trying to change a class value from webBrowser c#

尝试从 Windows 形式的 c# 中选中和取消选中 webBrowser 上的框。我只知道如何更改 elementbyid 值而不是 elementbyclass 值,如果存在的话...从 html 内部我可以从 "unchecked" 更改 class 值到 "checked"。但我不知道如何从 windows froms 中的 c# webBrowser 做到这一点。抱歉我的英语有限。谢谢

我试过的

webBrowser1.Document.GetElementById("signup-termservice").SetAttribute("unchecked", "checked");

如果我可以将此 class 的值更改为未选中到已选中就可以了...

<span class="unchecked" id="signup-termservice"></span>

通过更改 html class 它将选中复选框。

check out this a similar question u have to figure it out in your case.But i hope u r asking for something like this

首先,找到并获取HTML元素,改变className属性

HtmlElement htmlElement = webBrowser1.Document.GetElementById("signup-termservice");
if (htmlElement != null)
 {
  htmlElement.SetAttribute("ClassName", "unchecked");
 }