jquery验证中的errorPlacement无法正常工作

This is my code. When I validate it for gender and hobbies, a message appears just after the first radio input instead of at the end, I've tried error placement but bot working yet?

<tr>
    <td>Gender:</td>
    <td>
        <input type="radio" name="gender"  value="male" <?php if($a['gender']=='male'){ ?> checked <?php } ?> >Male
        <input type="radio" name="gender"  value="female" <?php if($a['gender']=='female'){ ?> checked <?php } ?> >Female
    </td>
    <td class="err"></td>
</tr>

<tr>
    <td>Hobbies:</td>
    <td>
        <input type="checkbox" name="hobbies[]"  value="cricket" <?php if(in_array(cricket,$a['hobbies'])){ ?> checked <?php } ?> >Cricket 
        <input type="checkbox" name="hobbies[]" value="chess"  <?php if(in_array(chess,$a['hobbies'])){ ?> checked <?php } ?>>chess 
        <input type="checkbox" name="hobbies[]"  value="wally"  <?php if(in_array(wally,$a['hobbies'])){ ?> checked <?php } ?>>Wally 
        <input type="checkbox" name="hobbies[]"  value="football"  <?php if(in_array(football,$a['hobbies'])){ ?> checked <?php } ?>>football
    </td>
    <td class="err"></td>
</tr>

jquery

<script>
errorPlacement: function(error, element) {
        if (element.attr("name") == "gender" )
            error.insertAfter(".err");
        else if  (element.attr("name") == "hobbies" )
            error.insertAfter(".err");
        else
            error.insertAfter(element);
    }
</script>

Please use InnerHTML For update the information.

$( ".err" ).html('your error output');

You want to insert element after <td class="err"> so it's not good idea. Better way might be put element inside tag <td> at the end. For example: $('.err').append('Error message');

Hobbies input name should be "hobbies[]"