使用JavaScript在文本字符串中插入隐藏的字符 [英] Insert an hidden character in text string using JavaScript

查看:73
本文介绍了使用JavaScript在文本字符串中插入隐藏的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用JavaScript在文本字符串中使用隐藏字符。有一个文本字符串,我用其中的隐藏字符读取和写回(因此重写文本看起来与原始文本相同,但它包含隐藏字符),所以,下次我阅读文本时,我可以知道这个文本已被阅读,因为它包含隐藏的字符

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 same as the original text though it comtains the hidden character), so that next time i read the text i can come to know that this text is aleady read as it contains the hidden character

例如)

< html>
< body>
< div>
This is a simple text
< /div>
< /body>
< /html>

我试图解析div并提取div的内容,并插入一个隐藏的字符文本并使用JavaScript再次将文本重写为div。

I am trying to parse the div and extract the contents of the div, and insert an hidden character to the text and rewrite the text to the div again using JavaScript.

我只是想知道我应该使用哪个隐藏字符插入文本?
如何将隐藏的字符写入文本?

I just want to know which hidden character should i use to insert into the text ? How to write the hidden character into the text ?

推荐答案

因为你使用的是javascript为什么不呢?向div添加一个属性: -

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;
    }
}

这篇关于使用JavaScript在文本字符串中插入隐藏的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆