+ 6
A value to The Button
how do i make value to the button
11 odpowiedzi
+ 3
maybe this will help
https://code.sololearn.com/WNnQrIe6zBEM/?ref=app
+ 11
<button onclick=
"document.write("welcome") >
</button>
+ 7
<button onClick="test()">Example</button>
<h1 id="wel"></h1>
<script>
function test(){
var write=
wel.innerHTML="WELCOME";
}
</script>
+ 6
👇
<input type="button" value="example">
+ 5
no i mean when i click on a button it writes welcome
+ 5
You can achieve that by using one of this two methods:
1. Displaying the message in an HTML element
<button onclick="welcomeMessage()">Click Me</button>
<div id="messagePanel"></div>
<script>
function welcomeMessage(){
var messagePanel = document.getElementById("messagePanel");
// displaying the message with textContent is preferable to innerHTML, because of the latter's security vulnerability
messagePanel.textContent = "Welcome!";
}
</script>
2. Use an alert to display the message.
<button onclick="welcomeAlert()">Click Me</button>
<script>
function welcomeAlert(){
alert(" Welcome!")
}
</script>
+ 2
thanks
+ 2
thanks for all for answer👍👍👍👍😉🌀
+ 1
<button onclick = “welcome();”>Click Me!</button>
<script>
function welcome() {
alert(“Welcome!”);
}
</script>
0
use this
<input type="button" value="example">
0
thank you it helps me