--- title: Selection.toString() slug: Web/API/Selection/toString translation_of: Web/API/Selection/toString ---
Selection.toString()
메소드는 selection 객체가 현재 나타내는 문자열을 반환합니다. 즉, 현재 선택된 텍스트의 문자열.
str = sel.toString()
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 |
---|---|---|
{{SpecName('HTML Editing', '#dom-selection-stringifier', 'Selection.toString()')}} | {{Spec2('HTML Editing')}} | Initial definition |