質問

I am working with DataTable and TableTools plugins with jQuery.

I am trying to simulate a keyPress (or keyUp), when someone clicks a link in the page.

html code :

<a href='#' id='return'>رجوع</a>

jQuery code :

$('#return').click(function() {
    e.preventDefault();
    $(this).trigger(// code here // );
});

I can't find the code to put there.

役に立ちましたか?

解決

Try this

$(this).trigger('keyup');

DEMO

Update

Try this :

$('#return').click(function(evt) {
    e.preventDefault();
    var evt = jQuery.Event('keyup');
    evt.keyCode = 27;
    evt.which = 27;
    $(this).trigger(evt);
    alert(evt.keyCode);
});

DEMO

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top