Cannot get text value from dropdown control jquery -


i have table users can add rows using append. options being updated dynamically.i have dropdown within row cannot find way text. can retrieve value only. i've tried replacing .val() .text() doesnt work.

<td>role<br/><select id="ddldepartment" class="ddldepartment" name="d1"><option value="">         select role</option></select></td>  <!-- language : lang-js -->  $("table.tbl_id_1").on("change", 'input[name^="txt"]', function (event) {         calculaterow($(this).closest("tr"));      });       function calculaterow(row) {     var price = +row.find('input[name="txtvision"]').val();     price += +row.find('input[name="txtinitiate"]').val();        var txtddl = +row.find('select.ddldepartment').val();     } 

i hope trying text of selected value select element.

try

var txtddl = +row.find('select.ddldepartment:selected').val(); 

the above code give selected value of select object. if want text inside selected item use

var txtddl = +row.find('select.ddldepartment:selected').text(); 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -