gpt4 book ai didi

Jquery Mobile 重置表单 html 5

转载 作者:搜寻专家 更新时间:2023-10-31 08:21:07 24 4
gpt4 key购买 nike

我有一个表单,我想在按下按钮时重置它。但我似乎无法让它工作。似乎输入类型范围已重置,但选择范围未重置。

HTML

   <form id="details_to_add">
<div data-role="fieldcontain">
<select id="select_company" data-native-menu="false" onchange="openNewcompanyDialog(this)" value="Company">
<option data-placeholder="company">Company</option>
<option value=""></option>
<option value="test">Test</option>
<option value="internal1">Internal</option>
<option value="new_company_option">Add a new company</option>
</select>
</div>

<div data-role="fieldcontain">
<select id="select_description" data-native-menu="false" onchange="handleInternalChoice(this)" value="Description">
<option data-placeholder="description">Description</option>

<!--Options to be shown when "internal" is chosen from company -->
<option value="internal1_1">Day off</option>
<option value="internal1_2">Time off</option>
<option value="internal1_3">Vacation</option>
</select>
</div>

<div data-role="fieldcontain">
<label for="number_of_hours">Number of hours:</label>
<input type="range" id="number_of_hours" value="0" min="0" max="24" step="0.25" />
</div>
<div data-role="controlgroup" data-type="horizontal">
<a href="#" data-role="button" data-rel="back">Close</a>
<a href="#" data-role="button" data-rel="back" onclick="pushData()">Save</a>
</div>
</form>

我已经尝试了多种方法来重置此表单,但如上所述,它只会重置 slider 。有什么建议吗??

最佳答案

你可以通过添加一个这样的按钮来解决它:

<a id="reset" data-role="button">Reset</a>

在 jQuery 的帮助下...

$('#reset').click(function() {
$('#number_of_hours').val('0').slider('refresh');
$('#select_company').val('Company').selectmenu('refresh');
$('#select_description').val('Description').selectmenu('refresh');
});

试试这里的例子:http://jsfiddle.net/KxakF/6/

关于Jquery Mobile 重置表单 html 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8973703/

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