• function

jQuery.within jQuery.within

 

jQuery(el).within(left, top)

Helps to determine all elements that have a certain position or area in common by providing jQuery.fn.withinBox and jQuery.fn.within. The following example returns all div elements on the point 200px left and 200px from the top:

$('div').within(200, 200)

Use $(el).withinBox(left, top, width, height) to get all elements within a certain area:

$('*').withinBox(200, 200, 100, 100)

jQuery.event.drag uses $.within to determine dropable elements at the current position.

jQuery(el).withinBox(left, top, width, height)

Returns all elements matching the selector that have a given area in common: $('*').withinBox(200, 200, 100, 100)

### Example

Move the mouse in the following example and it will show the ids for div elements within the current mouse position:

Parameters

  1. left {Number}

    the position from the left of the page

  2. top {Number}

    the position from the top of the page

  3. width {Number}

    the width of the area

  4. height {Number}

    the height of the area

  5. useOffsetCache=false {Boolean}Optional

    cache the dimensions and offset of the elements.

Returns

{jQuery}

a jQuery collection of elements whos area overlaps the element position.