jquery - Create a div before another -
i have script jquery validation engine. want set prompt div before div.
if($('#'+methods._getclassname(field.attr("id"))+'_msddholder').length ){ var prompt = $('<div>'); $('#'+methods._getclassname(field.attr("id"))+'_msddholder').before(prompt); prompt.addclass(methods._getclassname(field.attr("id")) + "formerror"); // add together class name identify parent form of prompt prompt.addclass("parentform"+methods._getclassname(field.closest('form, .validationenginecontainer').attr("id"))); prompt.addclass("formerror");
if won't work, if manually set this:
$('#'+methods._getclassname(field.attr("id"))+'_msddholder').before('<div>test</div>');
then works. why?
you apply class after before method. class won't apply on element. have tried :
var prompt = $('<div><h4>i test</h4></div>'); $('#'+methods._getclassname(field.attr("id"))+'_msddholder').before(prompt);
just see if have element insered ?
jquery dom jquery-validation-engine
No comments:
Post a Comment