nonopolarity
nonopolarity

Reputation: 151126

In jQuery, is this selector an older syntax and what does it do?

I see in the code there is

$(".add-to-list :select :selected")

using jQuery and we had jQuery 1.3.2, but upgraded to 1.4.2 recently. The line above actually says syntax error... was it for jQuery 1.3.2 but not 1.4.2, and what does it do -- any docs -- and how do you do that in 1.4.2? thanks.

Upvotes: 3

Views: 70

Answers (1)

Alex
Alex

Reputation: 65972

That selector looks for all option elements that are selected within all select elements in all elements that have a class of add-to-list.

The reason it is throwing a syntax error is that :select is not a valid selector. It was valid in 1.3.2, but has since been removed. Instead just use select to get HTML select elements.

The correct selector would be:

".add-to-list select :selected"

Upvotes: 7

Related Questions