代码之家  ›  专栏  ›  技术社区  ›  leora Matt Lacey

我可以在jquery中的mouseover上调用qTip吗(或者调用qTip的任何其他有效方法)

  •  1
  • leora Matt Lacey  · 技术社区  · 15 年前

    我有下面的代码,它工作正常,但似乎没有必要,因为它通过所有div.test循环,即使我从来没有鼠标在他们上面。我尝试将.qTip()函数放在mouseover事件中以提高效率,但这似乎不起作用。

    <script type="text/javascript">
        $(document).ready(function () {
    
            $('div.test').each(function () {
    
                var tooltipHtml = $(this).next('.tooltip').html();
                $(this).qtip({
                    content: {
                        text: tooltipHtml
                    },
                    style: { width: 450 }
                });
            });
        });
    
    1 回复  |  直到 15 年前
        1
  •  1
  •   Nick Craver    15 年前

    $(function () {
        $('div.test').each(function () {
            $(this).qtip({
                content: $(this).next('.tooltip'),
                style: { width: 450 }
            });
        });
    });
    

    content option 获取jQuery对象(在文档中称为jquerydom数组),因此不需要为每个对象爬网HTML。 但是