Reputation: 53
I am trying to replace all the jQuery dependency in the $(document).ready()
function.
document.addEventListener('DOMContentLoaded', function() {
$("#canvas1").mousedown(handleMouseDown);
$(document).keydown(handleKeyDown);
}, false);
If handleKeyDown and handleMouseDown are previously declared functions in the same file function handleMouseDown() and function handleKeyDown()
, how do I replace the jQuery with native javascript?
Upvotes: 0
Views: 67
Reputation: 2523
Have you tried:
document.addEventListener('DOMContentLoaded', function(){
document.getElementById('canvas1').onmousedown = handleMouseDown;
document.onkeydown = handleKeyDown;
}, false);
Upvotes: 4