最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to place jQuery Validate error message after the label? - Stack Overflow

programmeradmin0浏览0评论

I am using jQuery Validate and need to place the error message AFTER the label element. Currently, it's just inserting it after the input and before the element.

Can someone tell me how do this?

<td>
    <input type="text" id="name" name="name" class="text">
    <label for="name">Name</label>
</td>

errorElement: "div",
errorPlacement: function(error, element) {
    $(element).after(error);
},

I am using jQuery Validate and need to place the error message AFTER the label element. Currently, it's just inserting it after the input and before the element.

Can someone tell me how do this?

<td>
    <input type="text" id="name" name="name" class="text">
    <label for="name">Name</label>
</td>

errorElement: "div",
errorPlacement: function(error, element) {
    $(element).after(error);
},
Share Improve this question asked Jun 7, 2011 at 14:29 CofeyCofey 11.4k16 gold badges54 silver badges75 bronze badges 2
  • 1 $(element).next().after(error); ? – Sparkup Commented Jun 7, 2011 at 14:33
  • @Stack 101: That worked. Please add it as an answer and I'll mark it as accepted. Thanks! – Cofey Commented Jun 7, 2011 at 14:39
Add a ment  | 

1 Answer 1

Reset to default 6

This may help

$(element).next().after(error);

Demo : http://jsfiddle/sparkup/behLgebw/

发布评论

评论列表(0)

  1. 暂无评论