Insert an hidden character in text string using JavaScript

后端 未结 2 2008
终归单人心
终归单人心 2021-01-21 10:56

How to use an hidden character in text string using JavaScript.There is one text string which i read and writes back with the hidden character in it (so rewritten text looks sam

相关标签:
2条回答
  • 2021-01-21 11:41

    Since you are using javascript why don't you just add a property to the div:-

    var divs = document.getElementByTagName("div");
    for (var i = 0, length = divs.length; i < length; i++)
    {
        if (!divs[i].hasBeenRead)
        {       
             fnReadDiv(divs[i]);
             divs[i].hasBeenRead = true;
        }
    }
    
    0 讨论(0)
  • 2021-01-21 12:01

    To answer the question, keep an array of the divs that have been traversed:

    var divsChecked = [];
    //code that looks at the div
    divsChecked.push(div.getAttribute('id'));
    

    However I think that the method that you are using to traverse the items may not be correct with libraries like jQuery you could loop over each div in turn thereby you shouldn't ever see the same div twice unless you run the loop twice.

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