Simple&Basic JS - 1st attempt to javascript (want it jQuery free) -
Javascript's first attempt ... is not sure what I am doing ...
"sample cleansing Try here "when I hover or click the mouse or focus. And the warning when the button is clicked.
I recommend how I can use functions inside HTML and I can use them to completely separate JS / html. !
& lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; Java Script Practicing & lt; / Title & gt; & Lt; / Style & gt; & Lt; Script & gt; Document.onreadystatechange = function (if {document.readyState == "full") {// page loaded function (go) (warning ("done"); } Function clear () {var x = document.getElementById ("x"). Values; X = ""; }} & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form method = "post" & gt; & Lt; Input onclick = "clear ();" Type = "article" id = "x" value = "sample here" /> & Lt; Button onclick = "go ();" & Gt; Click! & Lt; / Button & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;
If you want to call your work from html, you need They should be in the global scope
Definitions for the function go ()
and clear ()
out of onreadystatechange
function. You can still use that function for <2> call for the other two, but they should be defined globally.
In addition, you can only use the variable x < Can not change the value of / code> and can update the element with id = x on that page. Instead, you can use
ELEMENT.setAttribute ('value', '')
to clear the value.
Go to function () {Warning ("done"); } Function clear () {var x = document.getElementById ("x"); X.setAttribute ('value', ''); } Document.onreadystatechange = function () {if (document.readyState == "full") {go (); clear(); }}
Comments
Post a Comment