当我按下按钮时,我有一个要重置的表单。但我似乎无法让它发挥作用。看起来输入类型范围是重置的,而不是选择的。
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>
我尝试了一些方法来重置此表单,但如上所述,它只会重置滑块。 有什么建议??
答案 0 :(得分:4)
您可以添加如下按钮来解决此问题:
<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/