jquery Gets the text content of the Select selection
Get value
The code is as follows |
Copy Code |
var checkvalue=$ ("#select_id"). Val (); Gets the value of the Select selection |
It took a long time to get out.
The code is as follows |
Copy Code |
$ ("#tid option:selected"). Text (); |
JS Gets the Select text value method as follows:
The code is as follows |
Copy Code |
var ts1 = ss.options[ss.selectedindex].text;//First or second ... |
You can also use innertext to get:
The code is as follows |
Copy Code |
var ts2 = ss.options[ss.selectedindex].innertext;//First or second |
Syntax Explanation:
var checktext=$ ("#select_id"). Find ("option:selected"). Text (); Gets the text selected by select
var checkvalue=$ ("#select_id"). Val (); Gets the value of the Select selection
var checkindex=$ ("#select_id"). Get (0). SelectedIndex; Get the index value selected by select
var maxindex=$ ("#select_id option:last"). attr ("index"); Get the maximum index value for select