0
Q:

onClick javascript

document.getElementById("myBtn").addEventListener("click", function() {
  alert("Hello World!");
});
9
 document.getElementById("Save").onclick = function ()
    {
     alert("hello");
     //validation code to see State field is mandatory.  
    }
2
var myElem = document.getElementByID('ElemID');
myElem.onclick = function() {
	//do stuff
}
10
// The element id (TheElementID) and var name (myElement) can be named anything.
var myElement = document.getElementByID('TheElementID');
myElement.onclick = function() {
	// Carry out a function here...
}
1
	<input type="text" name="text" id="test" onmouseover="skriv('klick')">
    <input type="button" name="send" value="Skicka" id="klick" onclick="skriv('test')">
    
    
    <script src="lib/script.js"></script>


// in lib/script.js

  function skriv(name) {
    document.getElementById(name).style.backgroundColor='red';
  }
1
//Wix Corvid Javascript example:
$w("#elementId").onClick(function functionName () {
  //Your function code
});
-2

New to Communities?

Join the community