javascript - What is the difference between $("selection") and $("selection", $(this)) -
i have seen utilize of $(this) , understand within function, have seen in selector well, fail understand when or if valuable. here 2 examples can utilize , work, doing valuable...
here added $(this) in selectors
(function($) { $(".deliver").on('mouseenter',function(){ $(this).css({'width':'600px'}); $(".form_jquery",$(this)).fadein(1000).css({'display':'block'}); $(".componentheading",$(this)).css({'display':'none'}); }); ...
here original script
(function($) { $(".deliver").on('mouseenter',function(){ $(this).css({'width':'600px'}); $(".form_jquery").fadein(1000).css({'display':'block'}); $(".componentheading").css({'display':'none'}); });
i have kept know standard utilize of (this) in both , noting using in anonymous function in case factors in.
$(".componentheading",$(this))
only searches .componentheading
elements under current $(this)
element (in particular case it's .deliver
entered mouse) whereas
$(".componentheading")
searches them in whole document.
http://api.jquery.com/jquery/#jquery1
javascript jquery anonymous-function
No comments:
Post a Comment