jQuery tooltip is not working

心不动则不痛 提交于 2019-12-11 11:32:00

问题


I want a tooltip to show when I rollover on particular links. It's not working. The commented out alert is working, so event is not the issue. This is my javascript code:

$(window).load( function() {

$("a").each(function() {
    if(this.text==" View image") {

        $(this).mouseover(function() {
//              alert("blabla");
            $(this).tooltip();
        });

    }

});

});

on my html file the includes are:

<script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" language="javascript" src="jquery.tooltip.min.js"></script>
<script type="text/javascript" language="javascript" src="mainscript.js"></script>

I'd appreciate some help.

UPDATE: removing mouseover doesn't help


回答1:


Remove the mouseover function. The plugin doesn't require you to add a custom mouseover function. It's done from the plugin for you.

if(this.text==" View image") {
            $(this).tooltip();
    }

Hope this helps ^^

Change the main jQuery function to $(document).ready(function(){});

This will probably work now~




回答2:


Try this:

$("a").each(function() {
    if(this.innerHTML == " View image") {
        $(this).tooltip();
    }
}

Also, there's a space before the View in "View image". I'm not sure if that's intentional or not.




回答3:


I used jQuery tipsy on my recent projects. Quite easy to understand and integrate.



来源:https://stackoverflow.com/questions/6940864/jquery-tooltip-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!