Wednesday, 19 April 2017
javascript - jQuery get specific option tag text
Answer
Answer
All right, say I have this:
What would the selector look like if I wanted to get "Option B" when I have the value '2'?
Please note that this is not asking how to get the selected text value, but just any one of them, whether selected or not, depending on the value attribute. I tried:
$("#list[value='2']").text();
But it is not working.
Answer
It's looking for an element with id list which has a property value equal to 2. What you want is the option child of the list.
$("#list option[value='2']").text()
Subscribe to:
Post Comments (Atom)
c++ - Does curly brackets matter for empty constructor?
Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...
-
Iv'e read a lot of posts both in stackoverflow and other websites talking about web security. Such as salting encrypting etc. ...
-
In K-PAX , there are two possible explanations: Prot is crazy. He is truly an alien. There are facts that indicate 1, but also 2. Examples: ...
-
System.out.print("Name : "); String name = in.nextLine(); System.out.print("Age : "); int age = ...
No comments:
Post a Comment