jQuery tip: Filter the selector DOM
That jQuery works with selectors using the patterns of CSS3 everybody know, and that apply in all dom you also know, but sometimes when you are using jquery you just want to filter a piece of DOM, not all DOM, and also apply some filter selector inside that DOM, here is the the tip:
1 2 3 4 5 | //some DOM var myHtml = $('<div><ul><li>1</li><li>2</li><li>sdasdasdasd</li></ul></div>'); //pass the myHtml by reference for the selector of jquery! var ul = $('ul', myHtml); |
The code can explain by his self, but describing a little bit more, we have some DOM and we want use the selector just in this piece of dom, we apply our selector in the first parameter and in the second we pass our DOM and that is it! The jQuery will inspect just the DOM that you specific.