I have the following piece of code, that i can't seem to convert to Jquery could someone help me out.
Pure JS working code:
var elements = document.getElementsByClassName("glyphicon glyphicon-comment");
for (var i = 0, length = elements.length; i < length; i++) {
$('#' + elements[i].id).tooltip();
}
}
My Jquery Attempts (both not working):
Attempt 1:
$(".glyphicon glyphicon-comment").tooltip();
Attempt 2:
$(".glyphicon glyphicon-comment").each( function() {
$(this).tooltip();
});
Example of the button:
<span class="glyphicon glyphicon-comment" data-toggle="tooltip" data-placement="left" id="commentTask1" data-original-title="This is comments"></span>
Could someone spot the error i've made?
Thnx for your efforts.
You need to use another dot .
without space to target elements by multiple classes:
$(".glyphicon.glyphicon-comment").tooltip();
and apply the same way for .each()
method:
$(".glyphicon.glyphicon-comment").each( function() {
$(this).tooltip();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With