Using JavaScript/JQuery I'd like to have a line of code that will simulate a series of key strokes. Specifically I'd like line of code that:
The idea being I'm using a flipbook plugin and there's a page search field as part of the plugin. I'd like to create a button that quickly takes you to a specific page. The easiest way I've figured to do that is simulate a series of key strokes after the button is clicked which acts as if the user clicked into the page search field and entered in a page number then hit return.
Could u maybe use:
document.getElementById('myTextarea').value = '';
document.getElementById("myForm").submit();
Where the first line replaces the text in the text area and the second one submits it
If you really need to use the return key, and can use jQuery:
var e = $.Event("keydown", { keyCode: 13}); //I think it is 13
$("body").trigger(e)
Or
var e = jQuery.Event("keypress");
e.which = 13; //choose the one you want
e.keyCode = 13;
$("#theInputToTest").trigger(e)
EDIT: Last one is also mentioned in the comments
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With