<html>
<head></head>
<body>
<input type="text" id="myid">
<button onclick="myfunc()">click</button>
<!-- This is the output placeholder -->
<p id="output"></p>
<script src="javascript.js"></script>
</body>
</html>
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
/* Select the output placeholder */
var outputElement = document.getElementById("output");
/* Set the input fields value as the text content */
outputElement.textContent = value;
}
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
/* Select the output placeholder */
var outputElement = document.getElementById("output");
/* Set the input fields value as the text content */
outputElement.textContent = value;
}<html>
<head></head>
<body>
<input type="text" id="myid">
<button onclick="myfunc()">click</button>
<!-- This is the output placeholder -->
<p id="output"></p>
<script src="javascript.js"></script>
</body>
</html><html>
<head></head>
<body>
<input type="text" id="myid">
<button onclick="myfunc()">click</button>
<!-- This is the output placeholder -->
<p id="output"></p>
<script src="javascript.js"></script>
</body>
</html>
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
/* Select the output placeholder */
var outputElement = document.getElementById("output");
/* Set the input fields value as the text content */
outputElement.textContent = value;
}
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
/* Select the output placeholder */
var outputElement = document.getElementById("output");
/* Set the input fields value as the text content */
outputElement.textContent = value;
}<html>
<head></head>
<body>
<input type="text" id="myid">
<button onclick="myfunc()">click</button>
<!-- This is the output placeholder -->
<p id="output"></p>
<script src="javascript.js"></script>
</body>
</html>- 1.4k
- 17
- 32
If you want to print the value of the input field, you can use console.log() to print it's contents to the console. Save the value of the input in a variable for example. Then you can log the value of this variable in your browser's console, or use it for another purpose.
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
console.log(value)
}
document.getElementById("myid").value did only get the input's value. But you didn't do anything with it.
You can also directly log the value without saving it to a variable first, see the example below.
function myfunc() {
"use strict";
console.log(document.getElementById("myid").value)
}
To show the value on the page, you can create a empty placeholder with an ID you can target. Then set the textContent of this placeholder to the value of the input. See the example below.
<html>
<head></head>
<body>
<input type="text" id="myid">
<button onclick="myfunc()">click</button>
<!-- This is the output placeholder -->
<p id="output"></p>
<script src="javascript.js"></script>
</body>
</html>
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
/* Select the output placeholder */
var outputElement = document.getElementById("output");
/* Set the input fields value as the text content */
outputElement.textContent = value;
}
If you want to print the value of the input field, you can use console.log() to print it's contents to the console. Save the value of the input in a variable for example. Then you can log the value of this variable in your browser's console, or use it for another purpose.
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
console.log(value)
}
document.getElementById("myid").value did only get the input's value. But you didn't do anything with it.
You can also directly log the value without saving it to a variable first, see the example below.
function myfunc() {
"use strict";
console.log(document.getElementById("myid").value)
}
To show the value on the page, you can create a empty placeholder with an ID you can target. Then set the textContent of this placeholder to the value of the input. See the example below.
<html>
<head></head>
<body>
<input type="text" id="myid">
<button onclick="myfunc()">click</button>
<p id="output"></p>
<script src="javascript.js"></script>
</body>
</html>
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
/* Select the output placeholder */
var outputElement = document.getElementById("output");
/* Set the input fields value as the text content */
outputElement.textContent = value;
}
If you want to print the value of the input field, you can use console.log() to print it's contents to the console. Save the value of the input in a variable for example. Then you can log the value of this variable in your browser's console, or use it for another purpose.
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
console.log(value)
}
document.getElementById("myid").value did only get the input's value. But you didn't do anything with it.
You can also directly log the value without saving it to a variable first, see the example below.
function myfunc() {
"use strict";
console.log(document.getElementById("myid").value)
}
To show the value on the page, you can create a empty placeholder with an ID you can target. Then set the textContent of this placeholder to the value of the input. See the example below.
<html>
<head></head>
<body>
<input type="text" id="myid">
<button onclick="myfunc()">click</button>
<!-- This is the output placeholder -->
<p id="output"></p>
<script src="javascript.js"></script>
</body>
</html>
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
/* Select the output placeholder */
var outputElement = document.getElementById("output");
/* Set the input fields value as the text content */
outputElement.textContent = value;
}
- 1.4k
- 17
- 32
The code looks fine, it doesn't do anything though except for getting the value of the input field..
If you want to print the value of the input field, you can use console.log() to print it's contents to the console. Save the value of the input in a variable for example. Then you can log the value of this variable in your browser's console, or use it for another purpose.
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
console.log(value)
}
document.getElementById("myid").value did only get the input's value. But you didn't do anything with it.
You can also directly log the value without saving it to a variable first, see the example below.
function myfunc() {
"use strict";
console.log(document.getElementById("myid").value)
}
To show the value on the page, you can create a empty placeholder with an ID you can target. Then set the textContent of this placeholder to the value of the input. See the example below.
<html>
<head></head>
<body>
<input type="text" id="myid">
<button onclick="myfunc()">click</button>
<p id="output"></p>
<script src="javascript.js"></script>
</body>
</html>
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
/* Select the output placeholder */
var outputElement = document.getElementById("output");
/* Set the input fields value as the text content */
outputElement.textContent = value;
}
The code looks fine, it doesn't do anything though except for getting the value of the input field..
If you want to print the value of the input field, you can use console.log() to print it's contents to the console. Save the value of the input in a variable for example. Then you can log the value of this variable in your browser's console, or use it for another purpose.
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
console.log(value)
}
document.getElementById("myid").value did only get the input's value. But you didn't do anything with it.
You can also directly log the value without saving it to a variable first, see the example below.
function myfunc() {
"use strict";
console.log(document.getElementById("myid").value)
}
If you want to print the value of the input field, you can use console.log() to print it's contents to the console. Save the value of the input in a variable for example. Then you can log the value of this variable in your browser's console, or use it for another purpose.
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
console.log(value)
}
document.getElementById("myid").value did only get the input's value. But you didn't do anything with it.
You can also directly log the value without saving it to a variable first, see the example below.
function myfunc() {
"use strict";
console.log(document.getElementById("myid").value)
}
To show the value on the page, you can create a empty placeholder with an ID you can target. Then set the textContent of this placeholder to the value of the input. See the example below.
<html>
<head></head>
<body>
<input type="text" id="myid">
<button onclick="myfunc()">click</button>
<p id="output"></p>
<script src="javascript.js"></script>
</body>
</html>
function myfunc() {
"use strict";
var value = document.getElementById("myid").value;
/* Select the output placeholder */
var outputElement = document.getElementById("output");
/* Set the input fields value as the text content */
outputElement.textContent = value;
}
- 1.4k
- 17
- 32