0% found this document useful (0 votes)
3 views2 pages

JavaScript Input Text Change Example

This document contains HTML and JavaScript code for a web page with an input field, button, and div element. The JavaScript code defines a variable to store the input field's text and assigns a click handler to the button. When clicked, the button gets the updated input text and sets the div's inner HTML to this new text, allowing the user to change the div content.

Uploaded by

Rajesh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

JavaScript Input Text Change Example

This document contains HTML and JavaScript code for a web page with an input field, button, and div element. The JavaScript code defines a variable to store the input field's text and assigns a click handler to the button. When clicked, the button gets the updated input text and sets the div's inner HTML to this new text, allowing the user to change the div content.

Uploaded by

Rajesh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Variables: variables.

html
!

<!doctype html>
<html>
<head>
<title>Learning Javascript</title>

<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />



</head>

<body>

<input id="myInput" type="text" value="test" />


<button id="stylesChanger">Change the text!</button>

<div id="firstDiv">This is some text</div>



<script type="text/javascript">


var newText=[Link]("myInput").value;


[Link]("stylesChanger").onclick=function() {

newText=[Link]("myInput").value;

[Link]("firstDiv").innerHTML=newText;

}

</script>

</body>
</html>

You might also like