Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onClick text change

so I'm pretty new with html and need some help.

I'm trying to make 3 buttons and each of them will change the text next to when you click on them. I am using the following code for each button:

<a href="#" onClick="document.getElementById('past').innerHTML='---future---';">

When I click on the button the text will change in the text after the innerHTML=" ". The problem is that one I add to much text on the places ---future--- it won't load it anymore in the browser. The screen just won't update. How do I overcome this problem? I've been having this problem for quite some time so any help will be appriciated.

like image 669
Jurjen van Genugten Avatar asked Jun 12 '13 11:06

Jurjen van Genugten


People also ask

How do I change text in HTML?

To change font type purely with HTML, use the CSS font-family property. Set it to the value you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a paragraph, heading, button, or span tag.


1 Answers

<script>
function changeText()
{
 document.getElementById('boldStuff').innerHTML = 'Fred Flinstone';
}
</script>
<p>Welcome to the site <b id='boldStuff'>dude</b> </p> 
<input type='button' onclick='changeText()' value='Change Text'/>
</body>
</html>

Try This Code. It Works For Me. In The Above Code I Have Used [bold] tag To Focus It You Can Use Acronym Tag.

like image 166
Divyam Solanki Avatar answered Oct 14 '22 20:10

Divyam Solanki