A function is triggered when the button is clicked. The function copies the text from Field1 into Field2.
Example:
HTML
<!DOCTYPE html>
<html>
<body>
Field1: <input type="text" id="field1" value="Hello World!"><br>
Field2: <input type="text" id="field2"><br><br>
<button onclick="myFunction()">Copy Text</button>
<p>A function is triggered when the button is clicked. The function copies the text from Field1 into Field2.</p>
<script>
function myFunction() {
document.getElementById("field2").value = document.getElementById("field1").value;
}
</script>
</body>
</html>
Example of HTML onclick Event Attribute | Mouse Events Attribute |
Definition and Usage of Definition and Usage | Mouse Events Attribute |
Browser Support of HTML onclick Event Attribute | Mouse Events Attribute |
Syntax of HTML onclick Event Attribute | Mouse Events Attribute |
Attribute Values of HTML onclick Event Attribute | Mouse Events Attribute |
Technical Details of HTML onclick Event Attribute | Mouse Events Attribute |
How to Execute a JavaScript when a button is clicked | Mouse Events Attribute |
How to Click on a <p> element to change its text color to red | Mouse Events Attribute |
How to Click on a button to copy some text from an input field to another input field | Mouse Events Attribute |
List of Mouse Events Attribute | Mouse Events Attribute |
What is HTML onclick Event Attribute | Mouse Events Attribute |
What is HTML ondblclick Event Attribute | Mouse Events Attribute |
Type: | Html |
Category: | Web Tutorial |
Sub Category: | Mouse Events Attribute |
Uploaded by: | Admin |