With jQuery, I'm trying to work out a way to send the words inside a span to a popup that appears when mousing over, I'm not sure sure how to send the text. I have the popup appearing, but I cant send the text.
So in this example I'd like the popup (class="popup") simply to say Hello World.
HTML:
<span class="text" data-id="#text1">Hello World</span>
<div class="popup" id="text1">This should just say Hello World, so this popup is wrong.</div>
JS:
$(document).on("mouseover", ".text", function() {
var id = $(this).data('id');
$(id).fadeIn();
}).on('mouseout', '.text', function() {
var id = $(this).data('id');
$(id).fadeOut();
});
CSS:
.text {background-color: red}
.popup {display: none}