Script text Property

❮ Script Object

Example

Get the contents of the <script> element:

var x = document.getElementById("myScript").text
Try it Yourself »

Description

The text property sets or returns the contents of the <script> element.


Browser Support

Property
text Yes Yes Yes Yes Yes

Syntax

Return the text property:

scriptObject.text

Set the text property:

scriptObject.text = contents

Property Values

Value Description
contents Specifies the contents of the script

Technical Details

Return Value: A String, representing the contents of the script. Returns all the text nodes that are children of the <script> element in tree order (other nodes, like comments or elements will be ignored).

More Examples

Example

Another example of how to get the contents of the <script> element:

var x = document.getElementById("myScript").text
Try it Yourself »
❮ Script Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.