Luca Reghellin
Luca Reghellin

Reputation: 8101

jquery ui tooltip items option not working

It seems for some reason the items option here doesn't work. I'm sure I'm doing something wrong but can't get the error. Can you help me?

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>test jquery</title>

<link rel="stylesheet" type="text/css" href="jquery-ui-1.10.3.custom.min.css" />
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.10.3.custom.min.js"></script>

<script>

    $(document).ready(function() {
        $(".div1").tooltip({ items: 'img[alt]'});
    }); 

</script>

</head>
<body>
<div class="div1">
    <img src="home-slider-next-button.png" width="26" height="24" alt="test2">
</div>
</body>
</html>

Upvotes: 0

Views: 851

Answers (1)

Luca Reghellin
Luca Reghellin

Reputation: 8101

Ok I took a closer look at the tooltip code and see that it seems it doesn't really take the alt attribute for content. It only uses items content as a selector. So my solution, for now, is to use the content option like this:

    $(document).ready(function() {
        $(".div1").tooltip({ items: 'img[alt]', content:function(){ return $(this).attr('alt'); }});
    });

hope it helps others with the same problem.

Upvotes: 1

Related Questions