如何使用 jQuery 选择的插件重置表单? [英] How can I reset a form with jQuery chosen plugin?

查看:25
本文介绍了如何使用 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 选择的插件重置表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆