jQuery.text() adds whitespaces between content of tags
I have Telerik Editor on my page. It seems to work fine on IE and Chrome.
As some of you probably know Telerik Editor is an iframe and text you see
is its body. I accessed that text, saved it to a variable with
jquery.html() method. Now from that variable I want to get pure text, no
markup/tags. Works fine on IE and Chrome, in Firefox jquery.text() adds
whitespace between tags. So if I had something like that:
<body>
    <p>
       <span>text</span><span>text2</span>
    </p>
</body>
I should get:
texttext2
as result of jquery.text(). In Firefox I get
text text2
There's a space added between tags which is unwanted. Any idea what's
wrong? Below's the code:
var uwagiFrame = $("#Szczegoly iframe").contents().find("body");
uwagiFrame.html(uwagiFrame.html().replace("<br>", ""));
uwagiFrame.html(uwagiFrame.html().replace(" ", ""));
var UwagiPozycji = uwagiFrame.html();
var uwagiBezStyliLength = uwagiFrame.text().length;
var uwagiBezStyli = uwagiFrame.text();
This way when untagged text goes to server there are additional spaces
which I'm unable to check for being redundant...
 
No comments:
Post a Comment