Wie man den markierten text statt Wert im dropdown-Menü

Ich versuche dem Benutzer ausgewählte Texte für mein dropdown-Menü.

Habe ich

   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.

         })

Habe ich google das Problem und alle die ich gefunden sind wie

$('#menu option:selected).text().

Gibt es sowieso zu bekommen, was ich brauche? Vielen Dank!

InformationsquelleAutor FlyingCat | 2013-01-04

Schreibe einen Kommentar