Reputation: 475
My code is
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.0.min.js"></script>
<script type="text/javascript" src="../../_js/jquery.tooltipster.min.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(document).ready(function () {
$('#HHH').tooltipster({
content: $('#BTE' )
})
})
</script>
My div is <div id="BTE">ABCDEFG</div>
and <div id="HHH"></DIV>
I want to hide my "BTE" initially and when hover AROUND "hhh", the "bte" should appear. I wonder how to achieve that? I had tried display:none
but it doesn't work.
Upvotes: 0
Views: 2406
Reputation: 19
This will update the tooltip with the content of the next hidden element (in my case a div with some html inside):
$(document).ready(function () {
$('.tooltip').tooltipster({
contentAsHTML: true,
updateAnimation: false,
functionBefore: function (origin, continueTooltip) {
continueTooltip();
if (!origin.data('cached')) {
var content = origin.next().contents(); // get the next div
origin.tooltipster('content', content).data('cached', true);
origin.tooltipster('show');
}
}
});
});
Upvotes: 0
Reputation: 475
Thank you all! I added $('#HHH').tooltipster({ content: $('#BTE' ).show() }), and add another div display none to my "BTE" and it works
as below:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.0.min.js"></script>
<script type="text/javascript" src="../../_js/jquery.tooltipster.min.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function () {
$('#HHH').tooltipster({
content: $('#BTE').show()
})
})
</script>
<div style="display:none">
<div id="BTE" style="display:none">Driven by: <ul><li>Economics of scale (cost advantage)</li>
<li>Patents and proprietary products</li>
<li>Brand strength</li>
<li>Government regulation</li>
<li>Capital investment requirements</li>
<li>Access to distribution channels</li>
</ul>
</div>
</div>
Upvotes: 0
Reputation: 25527
If you dont want to use any plugins, try like this,
// Initially hide the tooltip <div>
$("#HHH").hide();
// On mouse-over add some CSS and show the tooltip <div>
$("#BTE").mousemove(function (e) {
$("#HHH").css("top", e.pageY);
$("#HHH").css("margin-left", e.pageX);
$("#HHH").show();
});
// On mouse-out hide the tooltip <div> again
$("#BTE").mouseout(function () {
$("#HHH").hide();
});
Upvotes: 1
Reputation: 15393
Try like this: I analysed the plugin and put the solution for your issue. thanks
$(document).ready(function() {
$('#HHH').tooltipster({
content: $('<div id="BTE">ABCDEFG</div>')
});
});
<div id="HHH">
This div has a tooltip with HTML when you hover over it!
</div>
Upvotes: 0