Get the option value and text of select

 The methods for selecting the select tag in jQuery are:

$ ("# selectId") and $ ("select [name = 'selectName']")

1. Get the value of select, use val () directly after selecting:

for example: $ ("# selectId"). val () Or $ ("select [name = 'selectName']"). Val ();

2. Get the text value of select, after selecting select, use find ():

for example: $ ("# selectId"). Find ( "option: selected") text (); or $ ( "select [name = 'selectName']") Find. ( "option: selected") text (); ..

3. acquired select index selected

for example: $ ("#selectId"). get (0) .selectedindex;

 

Guess you like

Origin www.cnblogs.com/mjtabu/p/12721138.html