更新jquery插件选项而不刷新页面

update jquery plugin options without refreshing page

本文关键字:刷新 jquery 插件 选项 更新      更新时间:2023-09-26

我有一个插件倒计时,代码是:

 $("#submit").click(function(){
    Location.reload();
    $("#biscuit").biscuit({
       Width : $("#width").val(),
       BgColor : $("#BgColor").val(),
    });
 });

我创建了一个表单来更新饼干插件选项。表格如下:

<p class="title">width</p>
<input id="width" name="width" value="150">
<p class="title">bgColor</p>
<input id="BgColor" name="width" value="#654321">  
<button id="submit">submit</button>

我想在每次按下提交按钮后更新饼干插件选项。这些插件选项要求我刷新页面以更新插件。请帮助我找到一种方法,在按下提交按钮后更新我的插件选项。感谢

如果删除Location.reload();,Jquery选择器中的双引号就会出现一些错误。

我不是100%关注$.biscuit()以及插件是否以这种方式更新,但我会首先尝试删除Location.reload();,这实质上是重新加载页面,使其恢复到默认值。

这应该适用于您:

$("#submit").click(function(e){//now add e to your function
        e.preventDefault;//now prevent submit happen so it wont refresh
        Location.reload();
        $("#biscuit").biscuit({
           Width : $("#width").val(),//you forgot one " here
           BgColor : $("#BgColor").val(),//also you forgot one " here
        });
       });