Social Icons

twitterfacebookgoogle pluslinkedinemail

Friday 1 November 2013

How to get selected value or html content of dropdown or select using jquery

Hello Freinds,


if you want to get selected value or html content of dropdown or select using jquery then you can use on change event and also you can get all the attribute of selected option.

<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.2.js "></script>
</head>
<body>
<script type="text/javascript">
jQuery(document).ready(function(){
                jQuery('#select_id').change(function(){
//get content from dropdown option tag                   
                          alert(jQuery(this).find("option:selected").text());
                          alert(jQuery(this).find("option:selected").val());
                });
        });
 </script>

<select id="select_id" /><option value="1">option 1</option>
<option value="1">option 2</option>
<option value="1">option 3</option>
</select>
</body>
</html>

Live Demo







Thanks

Enjoy Your Self.

No comments :

Post a Comment

 

Free Advertisement

Free Advertisement

Free Advertisement

Free Advertisement