I would like to display text when I press a button [closed] - html

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I would like to know how to put a button on my code and when I click it, it displays text.
For example: when I click it and it should say thank you.
how I can put this in code form?

this is a code based on what I understood from your question
<!DOCTYPE html>
<html>
<body>
<button id="demo" onclick="myFunction()">Click me.</button>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "thank you!";
}
</script>
</body>
</html>

Related

Link visible according to date [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 days ago.
Improve this question
I have an html where I need to show a link after a determined date, For example I want that the link href='https://sample.it' will be visible only after 2023-02-25
I have no idea how to do
Assuming you are not using anything special, one of the possible solutions is to use PHP: put this code around your <a>.
<?php
if((new DateTime("now")) > (new DateTime('2023-02-25'))) {
?>
<a ...>...</a>
<?php
}
?>
We can do it using html and javascript
var currentdate = new Date();
if (currentdate < Date.parse('2023-02-25')) {
document.getElementById('link').style.display = 'none';
}
<!DOCTYPE html>
<html>
<title>HTML Tutorial</title>
<body>
<h1>This is a heading</h1>
<a href='https://sample.it' id='link'>https://sample.it</a>
</body>
</html>

How do I change a text after clicking an image in html? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 days ago.
Improve this question
Code I think
the door + text
the door changes into a open door after clicking it but is there a way for the 'woah' to change into for example 'text2' after clicking the closed door??
I'm new to html so I don't know much
someone told me to use document.getElementById but didn't give me any more information and I do not know where to put in the id
You can achieve what you want with basic Javascript, but if you don't know it yet, consider finding some good tutorial to get started.
The code you're looking for is something like
<!doctype html>
<html>
<head>
<title>Update Image and Text</title>
<!-- Define your function here -->
<script>
function updateImageAndText() {
//Update image url
document.getElementById("image").src = "https://via.placeholder.com/150/FFFF00/000000?text=open+door";
//Update paragraph text
document.getElementById("text").innerText = "New text";
}
</script>
</head>
<body>
<img id="image" src="https://via.placeholder.com/150/FFFF00/000000?text=closed+door" onclick="updateImageAndText()" />
<!-- Call your function here -->
<p id="text">Initial Text</p>
</body>
</html>

Make "Star" by HTML [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need some help with html)
I have this:
When i press to another "button" (like pig) text in the centre must change to another.
So question: what i need to use to make it. Maybe you have some example.
As I understand, you can solve your question with this:
<html>
</body>
<script>
function changeText()
{
document.getElementById('MiddleText').innerHTML = 'New Text in the middle';
}
</script>
<p id='MiddleText'>Your text in the middle</p>
<input type='myButton' onclick='changeText()' value='Change Text'/>
</body>
</html>

How to change color of products on a website? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am attempting to build a website that displays clothes such as t-shirts and pullovers. What I want is there to be an option to change the color of the products like this example.
Can someone help me with this?
Assuming you need this for a website, You can easily do it with a bit of HTML and Javascript.
<div id = "clothes">
<img src="#" id= "clothing">
<button onclick= "change()">Click here</button>
<button onclick = "change2()"> Click here</button>
<button onclick = "change3()"> Click here</button>
</div>
Now for your Javascript do:
function change(){
clothing.src = "#";
}
function change2(){
clothing.src = "#";
}
function change3(){
clothing.src = "#";
}
For more information about functions see here
Hope this helps!

How can I place a checkbox within a button? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am using Bootstrap and want to place a checkbox within a button, similar to what is done with Gmail to select all messages. I have looked at the Gmail CSS but have been unable to determine how they've done it.
Here is a simple example, made of DIVs with some CSS and a little jQuery to check the checkbox when the button is clicked:
jsFiddle demo
HTML:
<div id="container">
<div id="btnOuterDIV">
<div id="btnChkbox">
<input type="checkbox" id="btnCB" />
</div>
</div>
</div>
CSS:
#container {padding:50px;}
#btnOuterDIV{height:30px;width:80px;border:1px solid #ccc;border-radius:5px;}
#btnOuterDIV:hover{border-color:#888;cursor:pointer;}
#btnChkbox{height:15px;width:15px;padding-top:5px;padding-left:5px;}
jQuery:
$('#btnOuterDIV').click(function(){
alert('You clicked the button');
$('#btnCB').prop('checked',true);
});
Edit:
Button text (a label) added to the button: http://jsfiddle.net/crrojLho/2/