2011-03-03 63 views
0

如何为不同的输入类型设置不同的展示位置?更具体地说,如何在一个whos子标签出现错误类后添加另一个li?更清楚的是,我想指定fieldset“#SomeID”,错误元素在它们的父输入下面是一个新的div/li/p。jquery验证errorPlacement

<fieldset id="SomeID"> 
stuff 
<div class="toggle"><input type="checkbox" name="BP" id="BP">I have read and agree to the Billing Policy above.</div> 
<div class="toggle"><input type="checkbox" name="TA" id="TA">I have read and agree to the Terms and Agreement <a class="linkTA"><span>Learn More...</span></a></div> 
</fieldset> 

回答

0

你这个意思?

$("label.errorclass").append($("<li class='errmsg'>some error</li>")); 
+0

其实我的意思是使用的东西一样,如果(element.clsest( “#fieldsetID”)的长度。){error.appendTo(element.next( “礼”));但它不起作用 – 2011-03-03 03:11:19

+0

你可以发布你的html结构吗? – Quincy 2011-03-03 03:22:35

+0

我假设错误类是在切换div中分配的。尝试$(“div.errorclass”)。closest(“#fieldsetID”)。prepend($(“

some error
”)); – Quincy 2011-03-03 05:37:41

0

我想你想选择与错误类的li和使用$ .after直接插入一些html后。

$('li.error_class').after('<li>some stuff here</li>'); 
相关问题