如何使用selectboxit使用jquery重置选择框 我使用Fancybox在页面中间弹出一个div,它有一个选择框,用StultBox xjQuery插件描述:现在,我将select值更改为默认值以外的值,并关闭Fancybox。当我重新打开Fancybox时,选择值仍然与我选择的值相同。我需要它重置为默认值。 下面是我现在拥有的javascript代码: var selectBox = $("select").selectBoxIt(); $(".fancybox, #cartLink").fancybox({ width: 800, autoHeight: true, minHeight: 385, scrolling: 'no', autoSize: false, afterClose: function () { $(selectBox).val('0'); $(selectBox).refresh(); console.log('should be reset!'); } });

如何使用selectboxit使用jquery重置选择框 我使用Fancybox在页面中间弹出一个div,它有一个选择框,用StultBox xjQuery插件描述:现在,我将select值更改为默认值以外的值,并关闭Fancybox。当我重新打开Fancybox时,选择值仍然与我选择的值相同。我需要它重置为默认值。 下面是我现在拥有的javascript代码: var selectBox = $("select").selectBoxIt(); $(".fancybox, #cartLink").fancybox({ width: 800, autoHeight: true, minHeight: 385, scrolling: 'no', autoSize: false, afterClose: function () { $(selectBox).val('0'); $(selectBox).refresh(); console.log('should be reset!'); } });,jquery,jquery-plugins,Jquery,Jquery Plugins,“afterClose”(后关闭)功能的前两行不工作。第一个可能正在执行某些操作,但Firebug中的刷新行显示:“TypeError:$(…).refresh不是一个函数$(selectBox)。refresh();”您知道如何重置此selectBox吗 编辑:根据要求,这里有一把小提琴:您可以使用SelectBoxItselectOption()方法。像这样: $(document).ready(function () { var selectBox = $("select").

“afterClose”(后关闭)功能的前两行不工作。第一个可能正在执行某些操作,但Firebug中的刷新行显示:“TypeError:$(…).refresh不是一个函数$(selectBox)。refresh();”您知道如何重置此selectBox吗


编辑:根据要求,这里有一把小提琴:

您可以使用SelectBoxIt
selectOption()
方法。像这样:

 $(document).ready(function () {
     var selectBox = $("select").selectBoxIt();
     $("#cartLink").fancybox({
         width: 800,
         autoHeight: true,
         minHeight: 385,
         scrolling: 'no',
         autoSize: false,
         afterClose: function () {
             $(selectBox).selectBoxIt('selectOption', 0);
             $(".notification").hide();
             console.log('should be reset!');
         }
     });
 });

这里有一个到您更新的JSFIDLE的链接:

您能做一个JSFIDLE吗?这些插件通常只是在页面上抛出一些html,你可以删除它们,然后再调用初始化器,这正是我想要的。非常感谢。