Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Caesar Bell
25,198 PointsJavaScript value flashes but does not stay in the HTML page
When I enter in a username the value pops up in the div I want it to go, but it does not stay in the div (it flashes), it only stays if I put an alert in the code but once I click ok in the alert it disappears again
Below is my JS code
var answer = "Hello ";
document.getElementsByClassName("well-input")[0].innerHTML = answer;
function otherName(){
var input = document.getElementById("username").value;
answer += input;
document.getElementsByClassName("well-input")[0].innerHTML = answer;
alert(answer);
}
1 Answer
Caesar Bell
25,198 PointsFigure it out, its because I was using a form, so when the form send the info it refreshes the page.