$().bind() / $().trigger() jQuery Demo
I am a link
Trigger click
$(
function(){
// Get the action link.
jLink = $( "a:first" );
// Get the trigger link.
jTrigger = $( "a:last" );
// Bind several events to link.
jLink
.attr( "href", "javascript:void( 0 )" )
.bind(
"click",
function( objEvent ){
alert( "I am the FIRST event handler" );
// Prevent default.
return( false );
}
)
.click(
function( objEvent ){
alert( "I am the SECOND event handler" );
// Prevent default.
return( false );
}
)
;
// Hook up trigger link.
jTrigger
.attr( "href", "javascript:void( 0 )" )
.click(
function( objEvent ){
jLink.click();
// Prevent default.
return( false );
}
)
;
}
);