I've got stuck in a small piece of code. The setup is something like this -
<span class="span1">Something here</span>
<div><h3>Required Text</h3></div>
<span class="span2">Something here</span>
<div><h3>Required Text</h3></div>
<span class="span3">Something here</span>
<div><h3>Required Text</h3></div>
<span class="span4">Something here</span>
<div><h3>Required Text</h3></div>
<span class="span5">Something here</span>
<div><h3>Required Text</h3></div>
$(document).ready(function () {
var appendLblarr = [".span1", ".span2", ".span3", ".span4", ".span5"];
$.each(appendLblarr, function (i, val) {
var appendLabel = $(".span1 + div h3").text();
jQuery(val).mouseover(function(){
//alert();
$(this).append("<div class='appendedTT'><p>" + appendLabel + "</p></div>");
})
.mouseout(function() {
$( ".appendedTT" ).remove();
});
});
});
In the variable appendLabel, I'm trying to get the text of the <h3> which is in a <div> next to a <span>
The question is, how do i put that in a loop.
<h3>into theappendedTT<div>var appendLabel = $(appendLblarr + "div h3").text();or what is the correct syntax.