1. onselect
-
onselect event occurs when the text in the text box is selected
-
HTML tags support of the event:
<input type="text">
,<textarea>
-
Supported by the following JavaScript objects:
window
Example of use: -
<input type="text" value="Hello world!" onselect="alert('你已经选中了文字!')" />
That is, when the left mouse button and select the contents of the input across the input box, it will trigger onselect event.
2. onselectStart
-
onselectstart trigger time for the target object to be selected to start (ie, selected action started, yet substantive selected)
-
onselectstart can be used for almost all objects
-
Note: onselectstart event not to be input and textarea tag support
- Example of use (non-Firefox browser):
-
<div onselectstart="return false;">我不能被鼠标选中哦</div>
-
Firefox does not support the use of such above, in the Firefox browser, the same effect can be achieved by setting the CSS styles
-
div { -moz-user-select: none; }
-
That onselectstart event is the method used to correct the text within the element not selected to achieve.