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

Multiple attribute passing in querySelectorAll

Multiple attribute passing in querySelectorAll     Here I am demonstrating code to how to pass multiple attributes in querySelectorAll. <...

Ads Inside Post

Powered by Blogger.

Arsip