javascript onclick attribute


  Translation results:

on

英[ɒn]   美[ɑ:n]  

prep. (indicating direction) to; (indicating object) to; (indicating position) on...; (indicating time) at the time of...

adv. (put, wear, connect) on; forward, (continue) go on

adj. active situation, state ; in use; happening; planned

click

英[klɪk] 美[klɪk]

n.click sound ; claw, detent; [meter] (mouse) click; [linguistics] inspiratory sound

vt. Make a clicking sound

vi. Make a clicking sound; extremely successful; We hit it off, we hit it off; [calculation] rat click

Third person singular: clicks Plural: clicks Present participle: clicking Past tense: clicked Past participle: clicked

javascript onclick attributesyntax

Function: Occurs when the object is clicked.

Syntax: onclick="SomeJavaScriptCode"

Parameters: SomeJavaScriptCode Required. Specifies the JavaScript to be executed when this event occurs.​

javascript onclick attributeexample

<html>
<body>

Field1: <input type="text" id="field1" value="Hello World!">
<br />
Field2: <input type="text" id="field2">
<br /><br />
Click the button below to copy the content of Field1 to Field2.
<br />
<button onclick="document.getElementById('field2').value=
document.getElementById('field1').value">Copy Text</button>

</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance

Home

Videos

Q&A