Jquery with two or more subselectors

How to write a selector with two selectors, for example

$("#version option:selected **AND** option:contains('some text')")
+3
source share
4 answers

Just as you can use :visited:hoverin CSS, you can do the same in jQuery:

$("#version option:selected:contains('some text')")
+7
source

http://api.jquery.com/multiple-selector/

By the way, the correct use will be in your case:

$("#version option:selected, #version option:contains('some text')")

or

$("#version").find("option:selected, option:contains('some text')")

not

$("#version option:selected, option:contains('some text')")
+1
source

, "".

:

$("#version option:selected").find(":contains('some text')") //and so forth
+1

:

$("#version option:selected,#version option:contains('some text')")

http://api.jquery.com/multiple-selector/

, OP, , - . RoToRa .

0

Source: https://habr.com/ru/post/1776699/


All Articles