Example: A single-line script

This example shows a button with a single-line scriptA JavaScript program. as the value of the onclick attributeExtra information added to an element..

Try to guess how the page will change before clicking the button. This is the line that will be executed:

document.getElementById('answerhere').textContent='Replacement text.'

Note:

Hints:

  • undefined
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
<!DOCTYPE html>
<html lang="en">
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX