Morteza
Morteza

Reputation: 2153

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.

Upvotes: 0

Views: 6767

Answers (3)

James Allardice
James Allardice

Reputation: 165951

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().

Upvotes: 0

Mujah Maskey
Mujah Maskey

Reputation: 8804

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

try this.

Upvotes: 1

PicoCreator
PicoCreator

Reputation: 10154

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.

Upvotes: 2

Related Questions