I am trying to get the user selected texts for my dropdown menu.
I have
var selectMenu=document.createElement('select'); selectMenu.className='menu'; for(var i=0; i<array.length; i++){ var option=document.createElement('option'); option.className='option'; option.innerHTML=array[i].name; option.value=array[i].id; selectMenu.appendChild(option); } $(selectMenu).change(function(){ //i want to get the selected text here //I know I could get value by using $(this).val() //but not sure how to get the selected text here. }) I have google the issue and all I found are like
$('#menu option:selected).text(). Are there anyways to get what I need? Thanks a lot!