Is there a way to display the text content of an HTML element inside a tooltip? I am struggling to achieve this, as I would like to have the word test appear in the tooltip, but it's not working.
Unfortunately, we are not using jQuery in our code base, so I can't rely on any jQuery plugins. However, we do write JavaScript code as needed. Here is my current setup:
The HTML div looks like this:
<div class="tooltip message">test</div>
Here is the CSS setup:
.tooltip {
display: inline;
position: relative;
}
.tooltip.message:before {
background: #333;
background: rgba(0, 0, 0, .8);
border-radius: 5px;
bottom: 26px;
color: #fff;
left: 20%;
padding: 5px 15px;
position: absolute;
z-index: 98;
box-sizing: border-box;
}
.tooltip.message:after {
border: solid;
border-color: #333 transparent;
border-width: 6px 6px 0 6px;
bottom: 20px;
content:"";
left: 50%;
position: absolute;
z-index: 99;
}
Here is the link to my fiddle: http://jsfiddle.net/7LNJc/3/