Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM innerHTML property

HTML DOM innerHTML property

Element Object Reference Element object


Definition and Usage

The innerHTML property sets or returns the HTML between the start and end tags of a table row.

Syntax

HTMLElementObject.innerHTML=

text


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the innerHTML property


Example

Example

Change the text, URL, and link target:

<

!

DOCTYPE

html

<

html

<

head

<

meta

charset

=

"

utf-8

"

<

title

Runoob Tutorial(runoob.com)

title

<

script

function changeLink(){ document.getElementById('myAnchor').innerHTML="RUNOOB"; document.getElementById('myAnchor').href="//www.runoob.com"; document.getElementById('myAnchor').target="_blank"; }

script

head

<

body

<

a

id

=

"

myAnchor

"

href

=

"

//www.microsoft.com

"

Microsoft

a

<

input

type

=

"

button

"

onclick

=

"

changeLink()

"

value

=

"

Modify the link

"

body

html

Try it »


Element Object Reference Element object