点击<button>
时,我将填写输入字段的值并直接提交。输入字段如下所示:
<input aria-label="Ask me something..." autocomplete="off"
placeholder="Ask me something..." autofocus="autofocus" type="text"
class="queryform">
我已经尝试过类似的操作,但是无法提交:
document.getElementsByClassName("queryform")[0].value='Hallo Joris'
var e = new Event("keyup");
e.key='Enter';
e.keyCode=e.key.charCodeAt(13);
e.which=e.keyCode;
e.altKey=false;
e.ctrlKey=true;
e.shiftKey=false;
e.metaKey=false;
e.bubbles=true;
document.getElementsByClassName("queryform")[0].dispatchEvent(e);
您可以在gowogo.com上玩耍