I am new to Javascript and its syntaxes. Hope you all can help clear my doubts.
Q1)
<script>
$(document).ready(function() {...}
</script>
What does the "$(document...." part mean? I thought a function is started with
function(var){...}
? What the Difference? and when do i use "$" symbol?
Q2)
Js code
$('#dropzone').on('dragover', function(e) {
e.preventDefault();
e.stopPropagation();
e.originalEvent.dataTransfer.dropEffect = 'copy';
});
Html code
<div id="dropzone">
<span>Drop an image file here</span>
<canvas></canvas>
</div>
Based on the above, I see that "#dropzone" is linked to the "div id='dropzone'", correct? and i dont get the part of " function(e)"? what role does puting a function at that spot denotes?
Thank For your replies :)
$is a shortcut reference tojQueryas long as it's loaded on the page..readyis a specialjQueryfunction that can only be called on thedocumentwhich calls whatever function (function() {...}) it wraps when the page is done loading. You're very new, so learn JavaScript syntax first and when this all makes sense, you can move ontojQueryand the$syntax. The.onis similar to JavaScript's.addEventListener. Again, learn the basics first. Make some playful apps and read a lot of tutorials. JavaScript is fun once you understand it. Good luck!