all dynam...">

JQuery: add fieldset element between form

How to insert post fieldset using jquery, now I have this

<form action="" method="post">

all dynamic field generated with db and array

</form>

      

I want to add a fieldset between the form tags so that the code becomes

<form action="" method="post">
<fieldset>

all dynamic field generated with db and array

</fieldset>
</form>

      

+3


source to share


2 answers


I would recommend doing this backend, but if you really need to use jQuery to do this:

$('form').wrapInner('<fieldset />');

      



Fiddle

.wrapInner

docs

+5


source


or you can do it like this:



    var newForm = "<fieldset>"+$('form').html()+"</fieldset>";
    $('form').html(newForm);

      

+2


source







All Articles