jQuery.paste()


jQuery.paste()Returns: Boolean

Description: Pastes clipboard contents to text field.

Note: This function is only availible in the withPaste version of jQlipboard.

This is functionally identical to using navigaror.clipboard.writeText() (or document.execCommand if available in the user's browser) or simply pressing Ctrl + V. Upon a successful execution, this function will return true.

This function will fail if the document is not focused.

Consider the following example:

1
2
3
4
5
6
7
<div>
<input type="text" />
</div>

<script>
$( "input" ).focus();
</script>

The textfield will be focused. From there, we can call the paste function.

1
$.paste();

The conetnts of the clipboard will be pasted into the textfield, if a paste can be perfeormed. This process will work as if you pasted by right-clicking or by using keyboard shortcuts, but will not invote a pasting event listener.