When passing context to a selector, is it better to pass this or $(this) ? I tried the last one and it worked; document mentioned first.
this
$(this)
$('.link').on('click', function () { $('.element', this).addClass('something'); // or, $('.element, $(this)).addClass('something'); ? }
Using:
$(this).find('.element').addClass('something');
$('.element', this) will turn into $(this).find('.element') internal.
$('.element', this)
$(this).find('.element')
Source: https://habr.com/ru/post/1435911/More articles:How to make a thought bubble using basic graphics in iPhone - iosJava ProGuard. Keep class (not delete), but still allow to be confused - javaBest approach to disable link resolution? - tridionPDF does not load in Chrome - htmlHow to break C ++ Accept function? - c ++Request to send Ajax in ios Safari 6 not working - javascriptUsing onFling and ViewPager - androidBootstrap Timepicker Restart Start Time - twitter-bootstrapHow to add a ringtone to the application’s native contacts programmatically in android - androidJava arrow keys KeyPress launches numpad keys - javaAll Articles