سؤال

When a user does a specific event, I want to also simulate that they hit Ctrl+A in a textarea element. I know about caret positioning and selecting all text as a separate issue, but I don't want that. I want to be able to do it by just simulating Ctrl+A (using a cross-browser keycode) on that element.

هل كانت مفيدة؟

المحلول

You can do it using

$("#textareaid").select();

Control+A is targeting a selection.. You can't fake input as far as I know.. But you can do actions...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top