regular expression gives different output in FF and IE

前端 未结 1 841
无人共我
无人共我 2021-01-22 01:12

My problem is that when I use this code:

var queuediv = document.getElementById(\'MSO_ContentTable\');
var total = get_text(queuediv);
countTotal = total.split(/         


        
相关标签:
1条回答
  • 2021-01-22 01:51

    You are splitting by white space characters (line breaks, tabs ...). These seems to vary in DOM representation of different browsers. I assume you are trying to split words. Try:

    total.split(/ /).length;
    

    or

    total.replace(/\n\r\f/, '').split(/\s/).length
    

    you may replace \v and \t also.

    0 讨论(0)
提交回复
热议问题