What is the event
$(document).ready(function(){
$("a").click(function(event){
alert("Thanks for visiting!");
});
});
and also this one
$(document).ready(function(){
$("a").click(function(){
alert("Thanks for visiting!");
});
});
these two JS blocks are doing the same thing, but one with an event, if someone could explain what is function(event), also I saw something like function(e),function(g), what are those? Is there a tutorial I could learn?
The callback function that you’re providing to
$("a").clickis a function that takes an argument. This argument is an event object containing details about the object. Your function declaration can take this argument with any name you like —event,e,g… and it can also simply leave it out since you’re not using it inside of your function.Consider that these two functions are essentially the same:
And that you may leave out the argument if it’s not used: