Thursday, October 1, 2015

How to get selected value/Text of a drop down's item using jQuery?

In this below script,get selected value/Text of a drop down's item using jQuery

get selected value/Text of a drop down's item using jQuery

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="text/javascript">
$(document).ready(function(){ 
  
    alert($('#cmb_Type:selected').text());
 
});</script>
<select id="cmb_Type">
  <option value="1">Test 1</option>
  <option value="2">Test 2</option>
</select>
var dtype = $('select[Title^="cmb_Type"] option:selected').val();
var dtype = $('select[Title^="cmb_Type"] option:selected').text();

 $('#cmb_Type option:selected').val();
 $('#cmb_Type option:selected').text();

No comments:

Post a Comment