jquery possible function syntax and var scope
These are so far functions snytax that I've seen after been studying
jquery for a month. There are a lots of confusion. It is type 1 is bad
practice? because when u are develop something which is not small, they
will be some trouble, like collision and variable scoop problem. Type 2 in
my opinion is the best although it require some extra line of codes, in
large scale project on() is definitely a must to perform multiple method /
function on single element.
critic or correct me if I'm wrong.. btw, what is the e.target mean?
type 1 :
$(document).ready(function(){
$('.button').click(function(){
//do stuff
});
});
type 2:
$(document).ready(function(){
$(document).on('click','.button', myFunction)
function myFunction(e) {
//do stuff
}
)};
type 3:
$(document).on('click', '.button', function(){
//do stuff
)};
No comments:
Post a Comment