Javascript Removing Whitespace When It Shouldn't?

前端 未结 10 2065
谎友^
谎友^ 2020-12-11 05:29

I have a HTML file that has code similar to the following.


&         
10条回答
  •  甜味超标
    2020-12-11 05:32

    If someone could format my last post correctly it would look more readable. Sorry, I messed that one up. Basically the trick is create create a throwaway pre element, then append a copy of your node to that. Then you can get innerText or textContent depending on the browser.

    All browsers except IE basically do the obvious thing correctly. IE requires this hack since it only preserves white-space in pre elements, and only when you access innerText.

提交回复
热议问题
Hello World