[英]Auto click on button (In Wordpress)
在這段代碼中:
<div id="tagsdiv-post_tag" class="postbox " >
<div class="inside">
<div class="tagsdiv" id="post_tag">
<div class="jaxtag">
<div class="ajaxtag hide-if-no-js">
<p><input type="text" id="new-tag-post_tag" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
<input type="button" class="button tagadd" value="Add" tabindex="3" /></p>
</div>
</div>
</div>
</div>
</div>
我想自動點擊這個按鈕:
<input type="button" class="button tagadd" value="Add" tabindex="3" />
我試過這段代碼:
$(".ajaxtag input.button").click();
但它不起作用。 那是從 Wordpress 管理帖子頁面獲取的代碼。
嘗試在按鈕上附加一個 ID,使用 jQuery 按 id 搜索按鈕,然后單擊它...僅當整個站點加載時。 下面的例子。
$(document).ready(function() {
document.getElementById('ButtonId').click();
});
其中 'ButtonId' 是您要單擊的按鈕的 ID
嘗試在您的按鈕上附加一些東西,它現在什么都不做。
$(".ajaxtag input.button").trigger('click');
嘗試這個。
在我看來,您的代碼確實有效 - 以這個小提琴為例。 請注意,您需要使用$(document).ready()
將此代碼放入 onload 事件中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.