문제

$('#pass').focusout(function(){
    alert(($(this).text().replace(/\n\r|\n/g,'')).length);
    if(($(this).text().replace(/\n\r|\n/g,''))===''){alert('please be true');$('#water').text('enter password');}
    });

I'm left with a length of 3 which doesn't show up if I do:

alert('_'+($(this).text().replace(/\n\r|\n/g,''))+'_');

i see

alert(__); 

even though the length is 3

these are some kind of tab spaces I think. how the hell can I remove them?

도움이 되었습니까?

해결책

try this

someText.replace(/(\r\n|\n|\r)/gm,"");

다른 팁

You may use (this)

replace(/\s/g,'')

\s matches a single white space character, including space, tab, form feed, line feed but don't know what your $(this).text() contains, so not sure about the result.

function __kill(text){return text.replace(/\n\r|\n|\r|\t/g,'');};

\t <<<---like this

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top