• Log in or sign up for an account here: https://www.sythe.org/login

innerHTML and getElementById()

rubiksmaster12

Active Member

$5 USD Donor
Joined
Aug 9, 2007
Sythe Gold
0
Messages
115
I've been trying to learn how to use innerHTML and getElementById() in javascript scripts but I can never get it to work. Does anyone know a good site to learn how to use those?
 
Ok, I'm trying to make a script that will count up as you click the button. I keep getting errors and I don't know what I'm doing wrong. Here's the code. I've tried a couple times and this was the latest attempt.

Code:
<script type="javascript">

score = 0;

function count() 
{
document.getElementById('click').innerHTML='Clicks: '+score+'';
score++;
}

</script>
<body>
<div id="click">Clicks: 0</div>
<form>
<input type='button' value='click' onClick='count();'>
</form>

</body>
 
Omg, I'm really stupid. I forgot to put "text/" in the script type. Didn't even realize it until I posted it. :P
 
Heheh, better watch out for simple things like that; overlooking something so small, especially in big pieces of code can really throw you off.
 
duelarena.gg
Back
Top