如何使用该表单类名在JavaScript中提交表单?
我正试图通过JavaScript提交一个表单,该表单动态来自GoogleAPI 表单没有名称。但是它有class如何使用该表单类名在JavaScript中提交表单?,javascript,Javascript,我正试图通过JavaScript提交一个表单,该表单动态来自GoogleAPI 表单没有名称。但是它有classname.my。问题是我想用它的类名提交表单 <form class="gsc-search-box" accept-charset="utf-8"> <table cellspacing="0" cellpadding="0" class="gsc-search-box"> <tbody> <tr> <td
name.my
。问题是我想用它的类名提交表单
<form class="gsc-search-box" accept-charset="utf-8">
<table cellspacing="0" cellpadding="0" class="gsc-search-box">
<tbody>
<tr>
<td class="gsc-input">
<input type="text" autocomplete="off" size="10" class=" gsc-input" name="search" title="search" style="background: none repeat scroll 0% 0% rgb(255, 255, 255);" dir="ltr">
</td>
<td class="gsc-search-button">
<input type="submit" value="Search" class="gsc-search-button" title="search">
</td>
<td class="gsc-clear-button">
<div class="gsc-clear-button" title="clear results">
</div>
</td>
</tr>
</tbody>
</table>
<table cellspacing="0" cellpadding="0" class="gsc-branding">
<tbody>
<tr>
<td class="gsc-branding-user-defined">
</td>
<td class="gsc-branding-text">
<div class="gsc-branding-text">
powered by
</div>
</td>
<td class="gsc-branding-img">
<img src="http://www.google.com/uds/css/small-logo.png" class="gsc-branding-img">
</td>
</tr>
</tbody>
</table>
</form>
技术支持
您需要做的是获取表单并调用其submit()
方法,如下所示:
document.getElementsByClassName("gsc-search-box")[0].submit();
您需要做的是获取表单并调用其
submit()
方法,如下所示:
document.getElementsByClassName("gsc-search-box")[0].submit();
如果所需表单是此类页面上的第一个元素。是否有方法使用类名跟踪一个页面上的所有表单?如果所需表单是此类页面上的第一个元素。是否有方法使用类名跟踪一个页面上的所有表单?