How can I select all text in a textbox and copy it to the clipboard using JavaScript / jQuery?

I have a textbox with an "Add to Clipboard" button next to it. Whenever the copy to clipboard button is clicked, I want the contents of the clipboard to be copied to the clipboard and run in the browser via Internet Explorer, Firefox, Chrome, Opera, etc. I can use jQuery or regular JavaScript .

How can I do that?

+2


source to share


1 answer


It looks like the jQuery clipboard plugin can do the job well. You can also use selector notation besides the utility$.copy

EDIT:



ZeroClipboard is a different choice and it looks like it works (tested in Firefox 3.5, IE 6 and Chrome)

+2


source







All Articles