user10088
user10088

Reputation: 61

jQuery Mobile reset dropdown form

I'm trying to have a reset button on my form.

The code works, but it doesn't refresh the dropdown form. So it has value 0, but it doesn't show it's new value.

How can I solve this problem?

<script>
$('#btn-reset').live('click', function() {
$("select#Wiel").selectedIndex = 0;  //this works
    $("select#Wiel").selectmenu({'refresh': true});   /this doesn't work
});
</script>

Upvotes: 2

Views: 857

Answers (1)

Ram
Ram

Reputation: 144739

$("select#Wiel").selectedIndex = 0;  // this works

No it doesn't work, because jQuery object has no selectedIndex property, you should convert the jQuery object to a DOM object first:

$("select#Wiel")[0].selectedIndex = 0;  // this does work

or:

document.getElementById('Wiel').selectedIndex = 0;

Upvotes: 1

Related Questions