Search code examples
jquerytooltip

JQuery tooltip not displaying


I'm trying to set a tooltip for some listed elements using jquery ui but I can't get the tooltips to show. I'm trying to apply a tooltip to all items using the tooltip class. Please check my code for problems...

HTML

<li>
<label>
  <input id="someid" type="radio" name="name" />
  <strong><span>text</span></strong></label>
  <a href="#" class="tooltip" title="some text"></a>
  <h4>text</h4>
</li>

JS

function showTooltip() {
$("#tooltip").each(function()
    {
        $(this).tooltip();
    };
};

Thanks :)


Solution

  • Your function must have a class selector: $(".class")... not $("#id")

    $(function(){
        showTooltip();
        function showTooltip() {
           $(".tooltip").each(function() {
               $(this).tooltip();
           });
        }
    });