Example: A single-line script

This example shows a button with a single-line script as the value of the onclick attribute.

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