如何搞定所有具有标题的元素?

时间:2014-01-05 21:16:41

标签: javascript jquery

如何在所有具有标题的链接或其他元素上显示技巧?

例如......

<a href="/home" title="Go back to the index page">Home</a>

所以我在悬停时看到“回到索引页面”,但是没有id,我想它基本上是一个工具提示?

3 个答案:

答案 0 :(得分:0)

$('*[title]').tipsy();

这应该这样做。

答案 1 :(得分:0)

你可以尝试

$('[title!=""]').tipsy();

答案 2 :(得分:0)

如果我理解正确你正在寻找类似的东西:

<强>编辑:

// Select all elements in body     
$('body *').each(function() {
    // check if element has title
    if ($(this).attr("title")) {
        // Start tipsy
        $(this).tipsy();
    } else {
       // Do something or exlude *else* if u dont need
    }
});
相关问题