Skip to content

Instantly share code, notes, and snippets.

@pam-
Last active August 29, 2015 14:06
Show Gist options
  • Save pam-/771b4cde4ee18a4cca8e to your computer and use it in GitHub Desktop.
Save pam-/771b4cde4ee18a4cca8e to your computer and use it in GitHub Desktop.
jS shenan
div{
height: 100px;
width: 100px;
background: #C15244;
}
<div id="btn"> <a href="#"> Click me! </a> </div>
var button = document.getElementById('btn');
function doSomething(){
alert("I'm doing something!")
}
/*button.onClick = function() {
style.color = "blue";
}*/
// better than onClick:
button.addEventListener('click', doSomething());
button.addEventListener('mouseover', function(){
this.style.background = "blue";
});
button.addEventListener('mouseout', function(){
this.style.background = "#C15244";
});
document.querySelector('a').addEventListener('click', function(event){
//client side validation
event.preventDefault();
alert('You just cliked this link!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment