Sorry for my poor english.
During creating my private portfolio website, I found
textTest1();
textTest2();
function textTest1(){
var pText1 = $('p.textTest1').text();
var newString ='';
for(var i=0;i<pText1.length;i++){
console.log('total index of text1 is'+ i);
}
}
function textTest2(){
var pText2 = $('p.textTest2').text();
var newString2 ='';
for(var i=0; i<pText2.length;i++){
console.log('total index of text2 is' + i);
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="textTest1">text test</p>
<p class="textTest2">
text
test
</p>
these two p tags have different length. I understand why it happens
because I had similar problem with CSS.
No problem if text is small, but it would be annoying if text takes more
than two~three lines.
Writing all texts in one line can solve problem but if the text is very long and
there are some tags inside(example: span, i) it will be horrible to read
and find in text editor.
Does somebody have any idea to solve or avoid problem such like this? (I mean
to get a real and right length of text)