Mustapha George
Mustapha George

Reputation: 2527

jquery - trigger listener programmatically

This listener is currently triggered with a click in a ref in div shown below. Using jquery, how can I trigger the event programmatically? - or may be better to re-write the listener.

$("#flipPad a:not(.revert)").bind("click",function(){
    var $this = $(this);
    $("#flipbox").flip({
        direction: $this.attr("rel"),
        color: $this.attr("rev"),
        content: $this.attr("title"), 
        onBefore: function(){$(".revert").show()}
    })
    return false;
});

html:

<div id="flipbox">Message1</div>
<div id="flipPad">
<a href="#" class="left" rel="rl" rev="#39AB3E" title="Change content as <em>you</em> like!">left</a>
</div>

Upvotes: 0

Views: 527

Answers (2)

jahroy
jahroy

Reputation: 22692

You can do this:

$('#flipPad a:not(.revert)').click();

You can also do this:

$('#flipPad a:not(.revert)').trigger('click');

Links to documentation:

Upvotes: 1

Alex W
Alex W

Reputation: 38193

This should trigger it programmatically (fire the event handler):

$("#flipPad a:not(.revert)").click();

Upvotes: 1

Related Questions