I tried this using jQuery . This works very well with my localhost. But, nevertheless, I do not solve your problem or not.
I implemented javaScript as:
function submit(){ var numUsers=3; for (var i = 1; i <= numUsers; i++) { var tagId = '#otherUser' + i; var userName = $(tagId).text().toString(); $('#user').append("Username" + i + " : " + userName + "<br/>"); } }
And your HTML code:
<div id="otherUser1">userName1</div> <div id="otherUser2">userName2</div> <div id="otherUser3">userName3</div> <input type="button" value="Click Me!!" onclick="submit();"/> <div id="user"></div>
The DIV is currently displayed. But instead, HTML will automatically create PHP DIV files that will not be displayed later.
I also created this fiddle . I do not know why this does not work, even if it is the same!
Please correct me if I'm wrong somewhere.
Thank you.
EDIT : maybe jsfiddle does not support functions, (so the remote function line from javaScript)! So, update the fiddle and it works correctly.
user284291
source share