Problem:
How to get selected text of select from jquery?
While working in web programming sometime you need to get text from select box or combobox along with it's value.
Solution:
You will use .val() method to get value and use .text() method to get text from select box or combo box in jquery.
Example:
Use listed below code:
To get value:
var myval=$("#myselect").val();
To get Text:
var mytxt=$("#myselect :selected").text();
How to get selected text of select from jquery?
While working in web programming sometime you need to get text from select box or combobox along with it's value.
Solution:
You will use .val() method to get value and use .text() method to get text from select box or combo box in jquery.
Example:
Use listed below code:
To get value:
var myval=$("#myselect").val();
To get Text:
var mytxt=$("#myselect :selected").text();
0 comments:
Post a Comment