Posts

Showing posts with the label getElementById

Duke Coursera Javascript : Paint

Image
Another priceless one - a must do every few weeks. With practice, you should be able to build this one in about five minutes of coding - that's what it'll take to reach an elite level. Ok, I hadn't gotten the width-setting right at this point - because I hadn't yet used onchange="functionName()" . It's really simple - I thought you needed something elaborate (like this ) to be able to process the text-field when ENTER was pressed. But, no. You only need that to do a Google-suggest kind of autocomplete function.. To send the field value, functionName(this.value) . Powerful stuff :) Be sure to use input validation - check that the text field is numeric. https://codepen.io/chipdesigner/pen/poONPrQ

Why Doesn't this Work? Javascript getElementById onclick update..

Desired behavior : About button pressed : display text and change onclick to clear() (button text also changed) Clear (same button) pressed : go back to being ready for About to be pressed (onclick changed back to about() ) Using : <input id="aboutButton" type="button" onclick='doAbout()' value="About"> and function doAbout() {   document.getElementById("divabout").innerHTML = "by Ananth Chellappa<br>One Hour Design<br>Your questions answered within the hour";   document.getElementById("divabout").className="aboutcolor";   document.getElementById("aboutButton").onclick="clearAbout()";   document.getElementById("aboutButton").value="Clear"; } function clearAbout() {   document.getElementById("divabout").innerHTML = "";   document.getElementById("divabout").className="aboutcolor";   document.getElementById("ab...