[英]Tooltip text read from external file
In my php website I have a table with 100 rows, and for each cell I need seperate tooltips. 在我的php网站上,我有一个包含100行的表格,对于每个单元格,我需要单独的工具提示。 So I have a text file which have the set of texts for each cell. 所以我有一个文本文件,其中包含每个单元格的文本集。
I want to read the text from the external file and place it as the tooltip for each cells. 我想从外部文件中读取文本,并将其作为每个单元格的工具提示。
Can you guide me in solving this issue? 您能指导我解决这个问题吗?
<div class="divClass1" id="idClass1" >
<span title="My tip" class="context-menu-1">673</span>
<span title="My tip" class="context-menu-2">674</span>
<span title="My tip" class="context-menu-3">675</span>
<span title="My tip" class="context-menu-4">676</span>
<span title="My tip" class="context-menu-5">677</span>
<span title="My tip" class="context-menu-6">678</span>
<span title="My tip" class="context-menu-7">679</span>
</div>
This is one of the div and like this 100 others are there. 这是div之一,像这样的100个div在那里。 My external file is named dependecy.txt and it have data like 我的外部文件名为Dependecy.txt ,其数据如下
1 tooltip for cell1
2 tooltip for cell2
3 tooltip for cell3
4 tooltip for cell4
5 tooltip for cell5
6 tooltip for cell6
etc 等等
I want to replace title for class named: " context-menu-1 " with the text " tooltip for cell1 ". 我想用文本“ cell1的工具提示 ”替换名为“ context-menu-1 ”的类的标题。
You can create a json file with key and value pair,where cell id will be key and tooltip text will be value. 您可以创建具有键和值对的json文件,其中单元格ID为键,工具提示文本为值。 for example, 例如,
{
"toolTipInfo":{"cell1" : "tool tip text 1"},
{"cell2" : "tool tip text 2"},
. . .
{"cell100" : "tool tip text 100"}
}
now you can parse this json file in javascript and find values with respective keys. 现在,您可以使用javascript解析此json文件,并使用相应的键查找值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.