我在下面有这段代码,它运行良好,但似乎没有必要,因为它循环遍历所有 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 }
});
});
});