how to limit the jquery search scope

javascript, jquery

Solution

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')

Problem

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?

Original source