I'm really new to javascript
how do I make it that when I click a button
a number on my page in the <p> tag with
the Id of num gets 1 added to it
so it i like 2,3,4,5 each time I click
tommytom70
0
Newbie Poster
Recommended Answers
Jump to Post<html> <head> <script type="text/javascript"> function add() { //count number of label var ctr = document.getElementsByTagName("label").length; ctr = ctr + 1; var newElement = document.createElement('label'); if(ctr !== 1) { newElement.innerHTML = ', ' + ctr; } else { newElement.innerHTML = ctr; } document.getElementById("result").appendChild(newElement); } </script> </head> <body> <div> …
All 3 Replies
lambing
0
Light Poster
Graphix
commented:
This is clearly a homework assignment, and you just give him the code! Good job...
+0
lambing
0
Light Poster
tommytom70
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.