I am trying to get the innerhtml of an html element which contains self closing br tags<br/> but using .innerhtml converts the <br/> to <br> tag. I am working with IE10 And it has no XHTML parser to get innerhtml. This is the html:
<div>
<span>line 1<br/>line 2<br/>line 3</span>
</div>
I want to retain the self closing tag as it is but want to avoid using regEx. Can anyone help me with some other approach to achieve this?
innerHTMLconverts it to<br>because it should be<br>in html. If you want to use it as<br />in XHTML, you could replace<br>with<br />after getting the inner html. You could refer to the sample below: