Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
163
rated 0 times [  165] [ 2]  / answers: 1 / hits: 21628  / 11 Years ago, sun, june 23, 2013, 12:00:00

I currently have the following html within a pre-code block:



                <pre class=prettyprint><code>
&lt;html&gt;
&lt;body&gt;

&lt;form name=&quot;input&quot; action=&quot;html_form_action.asp&quot; method=&quot;get&quot;&gt;
&lt;input type=&quot;radio&quot; name=&quot;sex&quot; value=&quot;male&quot;&gt;Male&lt;br&gt;
&lt;input type=&quot;radio&quot; name=&quot;sex&quot; value=&quot;female&quot;&gt;Female&lt;br&gt;
&lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;
&lt;/form&gt;

&lt;p&gt;If you click the &quot;Submit&quot; button, the form-data will be sent to a page called &quot;html_form_action.asp&quot;.&lt;/p&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>


It is indented within the html source for better structure within the document. How can I remove the leading whitespace? Through the use of javascript or is there a more simple method.


More From » jquery

 Answers
7

You may want to just change how it is output, but it is fairly simple to do with JavaScript



var p = document.querySelector(.prettyprint);
p.textContent = p.textContent.replace(/^s+/mg, );


http://jsfiddle.net/a4gfZ/


[#77466] Friday, June 21, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alanisannettep

Total Points: 695
Total Questions: 96
Total Answers: 91

Location: Australia
Member since Sat, May 27, 2023
1 Year ago
;