I've some questions about callback function type in jQuery.
I don't have deep knowledge about javascript.
Here are simple codes in document level.
$("input").change(function(){
console.log(this);
});
And
$("input").change(()=>{
console.log(this);
});
Those log result are followings.
The first console log is the object of the input that is fired change event.
The second is the whole document.
What is the difference between function() and ()=>{} ?
Please help me.
Thanks.
I've attached the simple test source code.
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
console.log("init");
$(".first").change(function(){
console.log(this);
});
$(".second").change(()=>{
console.log(this);
});
});
</script>
</head>
<body>
<input type="text" class="first" />
<input type="text" class="second" />
</body>
</html>