tags:

views:

33

answers:

2

Hello all,

I saw the following usage of jQuery selector:

$('[value=""]', event.target).remove(); 

I can guess the meaning of this statement is to remove the option value="" from the selector event.target.

The pattern looks like $(A, B). What kind of selector rule is used here in jQuery?

Thank you

+3  A: 

See the documentation.

This code passes the context parameter, meaning that it will search only the children of the second parameter.
It's equivalent to $(event.target).find('[value=""]')

SLaks
Yep, and I'd typically write it with the `find()` method in preference. It's clearer about what's happening. The `$()` function is already terribly overloaded, let's avoid sticking more stuff in it!
bobince
+1  A: 

That snippet will remove all the elements which have the empty attribute value, descendants of the event.target element.

Example, removing all the links on the stackoverflow listing page:

jQuery('a', jQuery('#question-mini-list')).remove()
mhitza