Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Selection.toString() 메소드는 selection 객체가 현재 나타내는 문자열을 반환합니다. 즉, 현재 선택된 텍스트의 문자열.


str = sel.toString()

Return value

A string representing the selection.


This method returns the currently selected text.

In JavaScript, this method is called automatically when a function the selection object is passed to requires a string:

alert(window.getSelection()) // What is called
alert(window.getSelection().toString())  // What is actually being effectively called.


Specification Status Comment
HTML Editing APIs
The definition of 'Selection.toString()' in that specification.
Editor's Draft Initial definition

Browser compatibility

BCD tables only load in the browser

See also