gpt4 book ai didi

jQuery Mobile 重置下拉表单

转载 作者:行者123 更新时间:2023-12-01 04:58:59 25 4
gpt4 key购买 nike

我正在尝试在表单上添加重置按钮。

代码可以工作,但它不会刷新下拉表单。所以它的值为 0,但它不显示它的新值。

如何解决这个问题?

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

最佳答案

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

不,它不起作用,因为 jQuery 对象没有 selectedIndex 属性,您应该首先将 jQuery 对象转换为 DOM 对象:

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

或者:

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

关于jQuery Mobile 重置下拉表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11922215/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com