在查看了这个插件之后,我发现这个插件在它的源代码中有简单的解释。所以我测试了几分钟,找到了你问题的答案。
首先,您想将其起点从<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 中,只需删除 <div> 中的 class="jNice" 位置,该位置本身具有 form 元素(input,select,button,etc..)。插件会自动将它们更改为其样式。
其次,你说你想阻止某些部分执行他们的更改。转到 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); });
希望你觉得这很有用:)