简体   繁体   中英

How can I format output in jquery to a div?

I have created a form maker that allows me to create a form but can't format the output in a similar fashion to pretty print.

Tried using \\n and pre tags too

    allCont += "<label>"+insCleaned+"</label><input type='text' name='"+dval+insCleaned+"' /><p><?php echo "<?php if(isset(\$GLOBALS['postErrArray']['"?>"+ dval + insCleaned + "<?php echo "'])){echo \$GLOBALS['postErrArray']['"; ?>" + dval + insCleaned + "<?php echo "'];} ?>";?></p><br>";

                    $('#makeForm').append("<label>"+insCleaned+"</label><input type='text' name='"+insCleaned+"' /><br>");
                });

$('#showCode').text("<form method='post' action='ADD PATH' id='" + myForm +"'>" + allCont +"<input type='submit' value='Submit' id='" + myForm +"Submit' /><form>");

the output comes as one long line, I would like a way to format it and include line breaks.

If you just need it formatted clearly because you want to check once the code, I would use the features of the code editors to reformat it just once to check it; for example, the free editor PsPad has a "reformat HTML" command which reorders the code in a clear manner.

If on the other side you want to view in the page the generated code as viewed through an editor, remember you should escape all < to &lt; and > to &gt; , and surround this in PRE tags.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM