Bug Tracker

Opened 13 years ago

Closed 13 years ago

#6701 closed bug (invalid)

jQuery(HTMLElement, context) ignores context

Reported by: keith bentrup Owned by:
Priority: Milestone: 1.4.3
Component: unfiled Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:


If you pass an html element reference, then context is ignored.

Suppose you have this html:

<div id="my-div">...</div>

and this div is the target of a click event.

var myDiv = ev.target; $(myDiv, $('#possible-containing-div')); can give a different result than $('#my-div', $('#possible-containing-div');

It's because of this if statement: http://github.com/jquery/jquery/blob/master/src/core.js#L59

Here's my use case that led to this discovery: (It failed b/c context was ignored.)

$(document.body).click(function (ev) {

if ($(ev.target,$('#container')).length) return; code to execute if target element was NOT in container


Change History (1)

comment:1 Changed 13 years ago by dmethvin

Resolution: invalid
Status: newclosed

There is no signature of the form jQuery(element, context):


So this is not a bug.

For help in solving jQuery programming issues, ask on the forum.

Note: See TracTickets for help on using tickets.