Last active
August 29, 2015 14:06
-
-
Save pam-/771b4cde4ee18a4cca8e to your computer and use it in GitHub Desktop.
jS shenan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
div{ | |
height: 100px; | |
width: 100px; | |
background: #C15244; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="btn"> <a href="#"> Click me! </a> </div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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