jQuery.cut()


jQuery.cut()Returns: Boolean

Description: Cuts selected text to clipboard.

This is functionally identical to using document.execCommand or simply pressing Ctrl + X, but with some extra featured in case document.execCommand fails. Upon a successful execution, this function will return true.

Consider the following example:

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

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

The text field &endash; <input> &endash; will be selected. From there, we can call the copy function.

1
$.cut();

Any text that was inputed into the text field will be cut to the clipboard. This process will work as if you cut the text by right-clicking or by using keyboard shortcuts, but will not invote a cuting or copying event listener.