我有以下HTML:
<input class="vertical-tabs-active-tab" type="hidden" value="account" name="tabs__active_tab">
Run Code Online (Sandbox Code Playgroud)
我需要JavaScript将"帐户"的值更改为"yolo".
我以为我能做到这一点:
document.getElementsByClassName('vertical-tabs-active-tab').setAttribute("value", "yolo");
Run Code Online (Sandbox Code Playgroud)
但是这会产生以下错误:
document.getElementsByClassName(...).setAttribute is not a function
Run Code Online (Sandbox Code Playgroud)
我无法在输入中添加"id",我必须根据类更改值.