Menu
I want to display a string of characters, looking like a word, but I want to be able to single out any one of them to display in a different color, such as blue.
The string is assembled by a process that concatenates one character at a time.
Also I want to be able to hover the mouse on a blue character and bring up a pop-up message that explains why it’s blue.
Any advice?
I want to be able to single out any one of them to display in a different color, such as blue.[/QUOTE]AFAIK there is no other way than placing each character inside of a span and set the color for each.
The string is assembled by a process that concatenates one character at a time.[/QUOTE]Then it should be easy to create these span tags automatically.
I want to be able to hover the mouse on a blue character and bring up a pop-up message that explains why it's blue.[/QUOTE]Google for "css tooltip" and I'm shure you will find a proper solution, e. g. here:
<i>
</i><!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
var x = "dho";
var y = "t";
var z = "i";
var toggle = true;
function blackBlue()
{
if (toggle == true)
{
toggle = false;
[B]y = <span style="color:black">color </span>[/B] <br/>
}
else
{
toggle = true;
[B]y = <span style="color:blue">color </span>[/B]
}
<i> </i>document.getElementById("theText").innerHTML = x + y + z;
}
</script>
<p id="theText">dhoti</p> // ALL THE SAME COLOR, FOR STARTERS.
<button type="button" onclick="blackBlue()">Toggle</button>
</body>
</html>
y = <span style="color:black">t</span>
[code]y = <span style="color:blue">t</span>
document.getElementById("theText").innerHTML = letter[0] + letter[1] + letter[2] + <span style="color:blue">letter[3]</span> + letter[4]
[CODE] document.getElementById("theText").innerHTML = letter[0] + letter[1] + letter[2] + '<span style="color:blue">' + letter[3] + '</span>' + letter[4]
[/CODE]
document.getElementById("p1").innerHTML = outString;
[CODE]outString = outChar[0] + '<a class="tooltips" href="#">' + outChar[1] +
'<span>Your text for this char</span></a>' + outChar[2] +...[/CODE]
outChar = '<a class="tooltips" href="#">' + outChar + '<span>discrep</span></a>'
[CODE]outChar = '<a class="tooltips" href="#">' + outChar + '<span>' + discrep + '</span></a>'[/CODE]
a.tooltips {
position: relative;
display: inline;
}
a.tooltips span {
position: absolute;
width:140px;
color: #FFFFFF;
background: #000000;
height: 30px;
line-height: 30px;
text-align: center;
visibility: hidden;
border-radius: 6px;
}
a.tooltips span:after {
content: '';
position: absolute;
top: 100%;
left: 50%;
margin-left: -8px;
width: 0; height: 0;
border-top: 8px solid #000000;
border-right: 8px solid transparent;
border-left: 8px solid transparent;
}
a:hover.tooltips span {
visibility: visible;
opacity: 0.8;
bottom: 30px;
left: 50%;
margin-left: -76px;
z-index: 999;
}
Evidently I need to do something more than sandwich it between <style media="screen" type="text/css"> and </style>[/QUOTE]IMO this would be correct and sufficient. If it doesn't work after doing this there must be a different reason. Would be fine if one could view the page online and live. Can you post the URL?
outChar[colInd] = '<a class="tooltips" href="#">' + [COLOR="#0000FF"]outChar[colInd][/COLOR] + '<span>' + discrep[colInd] + '</span></a>'
[CODE]<style media="screen" type="text/css">
a.tooltips {
position: relative;
display: inline;
}
a.tooltips span.tt {
position: absolute;
width:140px;
color: #FFFFFF;
background: #000000;
height: 30px;
line-height: 30px;
text-align: center;
visibility: hidden;
border-radius: 6px;
}
a.tooltips span.tt:after {
content: '';
position: absolute;
top: 100%;
left: 50%;
margin-left: -8px;
width: 0; height: 0;
border-top: 8px solid #000000;
border-right: 8px solid transparent;
border-left: 8px solid transparent;
}
a:hover.tooltips span.tt {
visibility: visible;
opacity: 0.8;
bottom: 30px;
left: 50%;
margin-left: -76px;
z-index: 999;
}
</style>[/CODE]
[CODE]outChar[colInd] = '<a class="tooltips" href="#">' + outChar[colInd] + '<span class="tt">' + discrep[colInd] + '</span></a>' // from Webdeveloper forum
[/CODE]
0.1.9 — BETA 5.19