简体   繁体   中英

Auto click on button (In Wordpress)

In this code:

<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>

I want auto click on this button:

<input type="button" class="button tagadd" value="Add" tabindex="3" />

I tried with this code:

$(".ajaxtag input.button").click(); 

but it's not working. Thats code get from Wordpress admin post page.

Try attaching an ID to the button, using jQuery to search the button by id, and click it... Only when the entire site is loaded. Example below.

$(document).ready(function() {
     document.getElementById('ButtonId').click(); 
});

where 'ButtonId' is the ID of the button you want to click

Try attaching something to your button though, its not doing anything for now.

$(".ajaxtag input.button").trigger('click');

try this.

It appears to me that your code does work - see this fiddle as an example. Note that you need to put this code in the onload event, using $(document).ready() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM