Because you are passing the function this as an argument. this refers to the input element, so if you do console.log(obj); from within the function, you will see:
In this example we are passing in an event object and examining its type to determine what action to take.
There is no difference between the two methods in this context.
However, .on() has replaced .live() in jQuery 1.9 and can also be used to attach behaviour to dynamically created events.
Wait, but when I tried the reset and focus functions to remove and replace the default value, I don’t know how I’ll target it without the obj parameter that was originally being used. Do I just make it like this:
$("#go").focus(function(){
if ($("#go").val() == $("#go").prop('defaultValue')){
$("#go").val('');
}
});
$("#go").blur(function(){
if ($("#go").val() == ''){
$("#go").val('defaultValue');
}
});
It works just fine on the focus function, but if it’s empty on blur, ‘defaultValue’ is inserted as a result of the reset function.