How can I reset a form with jQuery chosen plugin?(如何使用 jQuery 选择的插件重置表单?)
问题描述
我在一个表单中有一堆 select 元素,我正在使用Jquery 选择插件.如何重置表格?以下方法不起作用:
I have a bunch of select elements in a form with which I am using the Jquery Chosen plugin. How can I reset the form? The following does not work:
<input type="reset" />
推荐答案
您需要重置该字段的值,然后在输入上触发 liszt:updated 事件以获取它更新,我在这里做了一个工作示例.
You'll need to reset the value of the field, then trigger the liszt:updated event on the input to get it to update, ive made a fiddle with a working example here.
http://jsfiddle.net/VSpa3/3/
$(".chzn-select").chosen();
$('a').click(function(){
$(".chzn-select").val('').trigger("liszt:updated");
});
自选择的 v1.0 发布以来,触发器现在称为选择:更新".使用此新版本的任何人都需要使用触发更新
Since the release of chosen v1.0 the trigger is now called 'chosen:updated'. Anyone using this new version needs to trigger the update using
$(".chosen-select").val('').trigger("chosen:updated");
这篇关于如何使用 jQuery 选择的插件重置表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 jQuery 选择的插件重置表单?
基础教程推荐
- 检查 HTML5 拖放文件类型 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
