The Range.toString()
method is a stringifier returning the text of the Range
.
Alerting the contents of a Range
makes an implicit toString()
call, so comparing range and text through an alert dialog is ineffective.
The Range.toString()
method is a stringifier returning the text of the Range
.
Alerting the contents of a Range
makes an implicit toString()
call, so comparing range and text through an alert dialog is ineffective.
js
toString()
None.
A string.
html
<p> This example logs <em>everything</em> between the emphasized <em>words</em>. Look at the output below. </p> <p id="log"></p>
js
const range = document.createRange(); range.setStartBefore(document.getElementsByTagName("em").item(0), 0); range.setEndAfter(document.getElementsByTagName("em").item(1), 0); document.getElementById("log").textContent = range.toString();
Specification |
---|
DOM Standard # dom-range-stringifier |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
toString |
1 | 12 | 1 | 9 | 9 | 1 | 4.4 | 18 | 4 | 10.1 | 1 | 1.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Range/toString