alert
at the top of your file and/or function and see if it shows up.form
tag on your page. If you do, it will treat any button click as an attempt to submit that form, which will refresh your page.
document.getElementByID
function work?
document.getElementById
.
textarea
in my JS code?
value
, not innerHTML
, of the text area.
for
or while
loop for animation work?
setInterval
function.
setInterval
to implement my timer, but I want to use setTimeout
instead. Is that okay?
setTimeout
would require you to keep setting timers over and over again, one to display each frame. This is inefficient for the browser. Use setInterval
.
id
or class
properties of an HTML tag in JavaScript?
.id
or .className
attributes respectively.
document.getElementById
) in global variables, because you can easily access these objects again by calling document.getElementById
again.
onclick
handler? document.getElementById("mybutton").onclick = myFunction(42);
document.getElementById("mybutton").onclick = f; ... function f() { myFunction(42); }
// anonymous function; may be bad style document.getElementById("mybutton").onclick = function() { myFunction(42); };