i have two problems
1- hide the default title attr
2- display the code html in the attr title (not the tags but the result)
i can't use any plugin
only the css and jquery(not jquery-ui) are allowed to use
thanks for help
/* Jquery */
$(document).ready(function(){
var content = ' \
<div class="title-inner"> \
<h2>Lorem ipsum</h2> \
<img src="https://placehold.it/200x200"> \
<p>Quisque efficitur </p> \
</div>';
$('#link').attr('title', content);
})
/*CSS*/
.box{
background-color: #f2f2f2;
width: 50%;
padding: 20px;
}
.box a{
color: #fff;
text-decoration: none;
display: inline-block;
background-color: #ff6600;
padding: 10px 30px;
border: 1px solid #ff6600;
}
.box a:hover{
color: #ff6600;
background-color: transparent;
}
.box a[title]:hover:after {
content: attr(title);
padding: 4px 8px;
color: #333;
position: absolute;
margin-right: -20px;
margin-top: 10px;
z-index: 20;
white-space: nowrap;
border-radius: 5px;
box-shadow: 0px 0px 4px rgba(0,0,0,0.5);
background-color: #fff;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Code HTML -->
<div class="box">
<a href="#" id="link" title="the title">Link</a>
</div>
<!-- this is the code to display in title attr-->
<!--
<div class="title-inner">
<h2>Lorem ipsum</h2>
<img src="https://placehold.it/200x200/ffff00/000000/?text=image-1" alt="image">
<p>Quisque efficitur arcu a sollicitudin consectetur. Etiam sit amet dui id sem porttitor faucibus non vitae sem. Donec tortor metus, tincidunt vitae viverra eu, pharetra mattis ipsum</p>
</div>
-->