File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 11781178 }
11791179 ` ` `
11801180
1181- - Scope jQuery object queries with find. [jsPerf](http: // jsperf.com/jquery-find-vs-context-sel/13)
1181+ - For DOM queries use Cascading ` $('.sidebar ul')` or parent > child ` $('.sidebar > .ul')` . [jsPerf](http: // jsperf.com/jquery-find-vs-context-sel/16)
1182+ - Use ` find` with scoped jQuery object queries.
11821183
11831184 ` ` ` javascript
11841185 // bad
1185- $('.sidebar ul').hide();
1186+ $('.sidebar', ' ul').hide();
11861187
11871188 // bad
1189+ $('.sidebar').find('ul').hide();
1190+
1191+ // good
1192+ $('.sidebar ul').hide();
1193+
1194+ // good
11881195 $('.sidebar > ul').hide();
11891196
1190- // bad
1191- $('.sidebar', ' ul').hide( );
1197+ // good
1198+ $sidebar.find(' ul');
11921199
11931200 // good
1194- $('. sidebar' ).find('ul').hide( );
1201+ $($ sidebar[0] ).find('ul');
11951202 ` ` `
11961203
11971204 ** [[⬆]](#TOC )**
You can’t perform that action at this time.
0 commit comments