[英]Press enter key on a web page
Fb組上有一個texbox。 這是html代碼:
<input type="text" class="inputtext textInput" name="freeform"
placeholder="Gruba Başkalarını Ekle" autocomplete="off" aria-autocomplete="list"
aria-expanded="false" aria-owns="typeahead_list_u_jsonp_4_2" aria-haspopup="true"
role="combobox" spellcheck="false" aria-label="Gruba Başkalarını Ekle"
id="u_jsonp_4_3">
然后使用javascript代碼輸入名稱。
document.getElementsByName('freeform')[0].value = '" + textBox2.Text + "';
但是沒有單擊的按鈕,我正在使用SendKeys.Send("{ENTER}")
事件單擊enter 。
問題是SendKeys.Send
對我來說還不夠,我想通過其他方式按Enter鍵。
如何在不使用SendKeys.Send
情況下按Enter鍵?
通過創建一個事件並分配Enter鍵的keyCode,可以很容易地在jQuery中實現這一點,即13
:
var e = jQuery.Event('keydown');
e.which = 13;
$('input[name="freeform"]').trigger(e);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.