Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to limit the jquery search scope

Tags:

It looks like JQuery does the search in the current document when using a selector.

How to search for an element only inside a div element?

like image 534
Buzz Avatar asked May 11 '12 00:05

Buzz


1 Answers

jQuery selectors work very much like CSS selectors, which you may be more familiar with.

First, select the div, and then descend from that:

$('#my-div').find('some-selector'). 

or build your selector to match children of the element in question:

$('#my-div some-selector') 
like image 70
meagar Avatar answered Sep 24 '22 09:09

meagar