Skip to content

Instantly share code, notes, and snippets.

@awongh
Last active August 29, 2015 14:23
Show Gist options
  • Save awongh/50a150ecedaccf177544 to your computer and use it in GitHub Desktop.
Save awongh/50a150ecedaccf177544 to your computer and use it in GitHub Desktop.
jquery translation exercises
//If these DOM elements don't exist yet, just create them!!!!!
// 1
var h3 = document.querySelector('h3');
// 2
var h3 = document.querySelector('h3');
h3.innerText = "Monkey Cheese";
// 3
var h3 = document.querySelector('h3');
h3.classList.add('fusia');
// 4
var button = document.querySelector('button');
button.addEventListener('click', function() {
console.log('hello!');
});
// 5
var li = document.createElement('li');
var body = document.querySelector('body')
li.innerText = 'Cheeseburgers';
li.classList.add('huge');
body.appendChild(li);
// 6
var button = document.querySelector('button');
var myFunc = function() {
console.log("WEEEE");
this.innerText = 'I WAS HOVERED OVER';
}
button.addEventListener('mouseover', myFunc);
// hover over button
button.removeEventListener('mouseover', myFunc);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment