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
$(document).keyup(function(e) { //keydown can be used as well. | |
switch(e.which) { | |
case 37: //left; any keycode can be used for each case. | |
alert('keycode: '+e.which); | |
break; | |
default: return; // exit this handler for other keys | |
} | |
e.preventDefault(); // prevent the default action (scroll / move caret) |
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 gulp = require('gulp'), | |
jade = require('gulp-jade'), | |
data = require('gulp-data'), | |
fs = require('fs'); | |
gulp.task('jade', function(){ | |
return gulp.src('src/jade/*.jade') | |
.pipe(data( function(file) { | |
return JSON.parse(fs.readFileSync('src/data.json')); | |
} )) |
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 newHTML = [ | |
'<div class="foo">', | |
'<p>Readable HTML in JavaScript.</p>', | |
'</div>' | |
].join(''); |
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
// getting an event's target | |
function getElementByEvent(event){ | |
console.log(event.target); | |
} | |
// get the target | |
var element = document.getElementsByClassName('element')[0]; | |
//adding event listener to target | |
element.addEventListener('click', function(event){ |
NewerOlder