I am new to programming and English language.
I am working on showing the tooltip with the dynamic content loading using CSS.
The problem is,
I am pushing the values that contains html element tags to the data-info attribute dynamically using JQuery. It is stored as a string and while displaying on tooltip it is showing with html tags as strings.
Is there any possible way to show the tooltip with the values formatted as HTML.
I'm trying with the following is the code:
var divContent ;
$(document).ready(function(){
function getContent(){
var divAry = [];
var str;
divAry.push("<li>ABC</li>");
divAry.push("<li>DEF</li>");
str = "<ul>"+divAry.toString().replace(/,<li>/g,"<li>").replace(/,/g,"")+"</ul>";
return str;
}
$('#linkId').mouseover(function(){
divContent = getContent();
var jObj = $($.parseHTML(divContent));
$(this).attr('data-info',divContent);
});
});
.tooltip{
display: inline;
position: relative;
}
.tooltip:hover:after{
background: grey;
border-radius: 5px;
color: #000;
content: attr(data-info);
top: 26px;
left: 40%;
padding: 5px 15px;
position: absolute;
z-index: 98;
width: 220px;
}
.tooltip:hover:before{
border: solid;
border-color: #333 transparent;
border-width: 6px 6px 0 6px;
top : 10px;
bottom: 100%;
content: "";
left: 50%;
position: absolute;
z-index: 99;
border-top: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid grey;
border-left: 10px solid transparent;
}
<script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.js"></script>
<a id="linkId" href="#" class="tooltip">Hover here</a>
Please anyone get me rid out of this.
Thanks in advance.