Last active
December 1, 2017 06:46
-
-
Save pardamike/f6cf94697702274fb2933e9a34cbf60e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* Attaching event listners with jQuery method 1: */ | |
$('#someElement').click(function (event) { | |
// Do something with the event | |
}); | |
/* Attaching event listners with jQuery method 2: */ | |
$(document).on('click', '#someElement', function (event) { | |
// Do something with the event | |
}); | |
/* Attaching event listeners with Javascript */ | |
document.getElementById('someElement').addEventListener('click', function (event) { | |
// Do something with the event | |
}); | |
/* You can also do click events in JS this way */ | |
document.getElementById('someElement').onclick = function (event) { | |
// Do something with the event | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment