actually i am trying to insert these(<div class="error_msg_div"><div class="error_msgicon_div"><span class="sprite_16x16_group_errorinfo fl rmar5"></span></div><div class="error_msgtext_div">) things before the ul
and these(</div><div class="error_msgcloseicon_div"><span class="sprite_16x16_group_blueclose_icon fl curpointer"></span></div><div class="clearfloat"></div></div>) things after the ul.
But here it is inserting the div tags but it closing the divs automatically but i don’t want that
because i am trying to push the ul to inside one div. that is not happening here
my jsfiddle is here
Here is my script:
if($('span.error_span:has(ul.validation-messages)')){
$('ul.validation-messages').before('<div class="error_msg_div"><div class="error_msgicon_div"><span class="sprite_16x16_group_errorinfo fl rmar5"></span></div><div class="error_msgtext_div">');
$('ul.validation-messages').after('</div><div class="error_msgcloseicon_div"><span class="sprite_16x16_group_blueclose_icon fl curpointer"></span></div><div class="clearfloat"></div></div>');
}
Be aware that you are manipulating the DOM with these functions, not just simply concatenating some strings containing HTML. You cannot append
</div>.You should use
wrap()to add that div around your lists, and then usebefore()andafter()to insert other divs.