AlanRubinoff
AlanRubinoff

Reputation: 385

How to get value of selected listview item jquery mobile

I have this

<div data-role="fieldcontain">
  <label for="selecionarPaisPreferencia" class="select">Pais</label>
  <select name="selecionarPaisPreferencia" id="selecionarPaisPreferencia">
    <!--Aca Se Cargan Dinamicamente Los Paises En las preferencias-->
  </select>
</div>

and the elements are dinamically loaded like this

for (i = 0; i < paises.length; i++) {
  $("#selectPaisConsulta").append('<option data-pais="'+paises[i]+'">'+paises[i]+'</option>');
}

the elements get loaded correctly there is a preference menu where you choose a country and when y click accept y want to store the value that was selected in the listview i have the atribute data-pais that stores the value if it is any help thank you!

Upvotes: 0

Views: 2336

Answers (1)

Sushanth --
Sushanth --

Reputation: 55740

You can just use the .val method

$("#selectPaisConsulta").val()

Upvotes: 1

Related Questions