Created
February 28, 2014 04:49
-
-
Save synackme/9265441 to your computer and use it in GitHub Desktop.
copy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given the following example html: | |
<div class="announcementInfoText"> | |
<p class="copyToClipboard"> | |
<a id="selectAll">Select All Text</a> | |
</p> | |
<textarea ID="description" class="announcementTextArea">This is some sample text that I want to be select to copy to the clipboard</textarea> | |
</div> | |
you can select the text within the textarea with the following jQuery: | |
$("#selectAll").click(function () { | |
$(this).parents(".announcementInfoText").children("textarea").select(); | |
}); | |
Now that the text "This is some sample text that I want to be select to copy to the clipboard" is selected, you can simply hit Ctrl+C and the text is copied to the clipboard. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment