2011-06-28 68 views
0

我有以下形式例如:LIVE DEMO腳本改變/辦法停止執行腳本

它是jNice(完整的腳本)運行:uncompressed versiuon

在項目中,我目前的工作 - 我需要它功能只在其一部分 - 在其他部分是沒有用的。

通過向表單元素添加'class =「jNIce」來調用腳本。

我在尋找:

  • 或者改變它的「起點」到div元素(未形成)
  • 或一種方法來阻止在它

一些地方執行任何建議我可以從哪裏開始?任何幫助非常感謝。

皮特

回答

1

檢查了這個插件後,我發現,這個插件在其源代碼很容易解釋。所以我測試了幾分鐘,找到了你的問題的答案。

首先,您想將其起始點從<form>改爲<div>或其他。打開jNIce插件代碼(.js),並滾動到文件的末尾,然後改變這一行:

/* Automatically apply to any forms with class jNice */ $(function(){$('form.jNice').jNice(); });

到:

/* Automatically apply to any forms with class jNice */ $(function(){$('div.jNice').jNice(); });

而在HTML中的body剛剛刪除的地方class="jNice"在其本身具有form元件(input,select,button等)。該插件會自動將其更改爲其樣式。

第二,你說你想停止執行他們的變化的一些部分。去jNice插件線27,那麼你會發現:

$('input:submit, input:reset, input:button', this).each(ButtonAdd); $('button').focus(function(){ $(this).addClass('jNiceFocus')}).blur(function(){ $(this).removeClass('jNiceFocus')}); $('input:text:visible, input:password', this).each(TextAdd); /* If this is safari we need to add an extra class */ if (safari){$('.jNiceInputWrapper').each(function(){$(this).addClass('jNiceSafari').find('input').css('width', $(this).width()+11);});} $('input:checkbox', this).each(CheckAdd); $('input:radio', this).each(RadioAdd); $('select', this).each(function(index){ SelectAdd(this, index); });

如果你想jNice停止改變,你不喜歡form元素,只是把評論\\或刪除其行。舉例來說,我不希望它select框的樣式,我把評論:

\\$('select', this).each(function(index){ SelectAdd(this, index); });

希望您覺得有用:)

0

發現改變jNice腳本調用的方法:最後一行之前

在一個我們有:

$(function(){$('form.jNice').jNice(); }); 

如果我們改變,要(表 - > DIV(或任何我們想要的))

$(function(){$('div.jNice').jNice(); }); 

這樣我們可以調用jNice任何我們想要的(元素包裝或元素它自己)。

註冊