I currently have the following html within a pre-code block:
JavaScript
x
16
16
1
<pre class="prettyprint"><code>
2
<html>
3
<body>
4
5
<form name="input" action="html_form_action.asp" method="get">
6
<input type="radio" name="sex" value="male">Male<br>
7
<input type="radio" name="sex" value="female">Female<br>
8
<input type="submit" value="Submit">
9
</form>
10
11
<p>If you click the "Submit" button, the form-data will be sent to a page called "html_form_action.asp".</p>
12
13
</body>
14
</html>
15
</code></pre>
16
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.
Advertisement
Answer
You may want to just change how it is output, but it is fairly simple to do with JavaScript
JavaScript
1
3
1
var p = document.querySelector(".prettyprint");
2
p.textContent = p.textContent.replace(/^s+/mg, "");
3