For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Friday, November 07, 2014

get selected text of select from jquery

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();
Share:

0 comments:

Post a Comment

Add Dependent Scripts

   here is the code that allow to add dependent script :         <script>         const addDependentScripts = async function( scriptsT...

Ads Inside Post

Powered by Blogger.

Arsip