q0987
q0987

Reputation: 35992

jQuery - what is the feature of this selector rule?

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

Upvotes: 0

Views: 68

Answers (2)

mhitza
mhitza

Reputation: 5715

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

Upvotes: 1

SLaks
SLaks

Reputation: 887807

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=""]')

Upvotes: 3

Related Questions