Removing a line inside <pre class = "prettyprint-override"> from the DOM
When I delete a line from the <pre> , the rest of the lines below it do not move as if they were using the standard <div> or any other element.
You can see an example of this at http://jsfiddle.net/NN6LC/
Has anyone encountered this problem before or knows how to solve it?
You delete the span, but a new line still exists.
And technically you are not even allowed to have a <span> in a <pre> .
From http://lib.ru/WEBMASTER/elements.html#PRE :
Items allowed inside ...
<A><HR><BR>elements and parsed character data.
The way to it is to use <div> instead of <pre> and set the styles in the div so that it looks like a <pre> .
EDIT: Someone else posted the answer below and then deleted their answer. I do not know why, since it was a good answer. But so they did:
If you do not need a <span> not technically permitted, you can manually delete it and the new line as follows: http://jsfiddle.net/doktormolle/KgYyp/
function removeLine() { var line=$('pre span.line_1'); if(line.length) { if(line[0].nextSibling && line[0].nextSibling.nodeType == 3) { line[0].parentNode.removeChild(line[0].nextSibling); } } line.remove(); } This will check the new line after the item before deleting it and delete the new line if it exists.
What a curious behavior. Here is the path around it, but I admit it is not entirely satisfactory.
Add the following CSS:
pre {white-space: normal} pre span {display: block} See http://jsfiddle.net/tG8V6/ for the working version.