19

I have two kind of elements

<i rel="tooltip" class='icon-ok'>
<i title="Teste" class='icon-info'>

The first one is a tooltip effect, the second a popover

What I'm trying to do is avoid rework so I don't need to create a script based on the class on every html I have.

I did this on my base html:

$('body').find('i').tooltip();

The problem is that it is adding the tooltip effect on the other <i> elements without the rel attribute.

I need to search for elements with the rel attribute and set the tooltip effect on them.

Thanks

EDIT

If I try to do the opposite of what was said on the correct answer, get the <i> elements without the rel attribute. Found the solution here: jQuery selectors - find objects without specified attribute

vrutberg - jQuery("li:not([style])").hide();

4

3 に答える 3

26

正確なもの

$('i[rel="tooltip"]').tooltip()
于 2012-04-04T16:53:49.770 に答える
23

$('i[rel]').tooltip();

http://api.jquery.com/category/selectors/attribute-selectors/

于 2012-04-04T16:48:27.567 に答える
2

yonは、このセレクターを使用してhrefattですべての要素を選択できます

$(document).ready(function()
{

$("[rel]")

});
于 2012-04-04T16:52:02.297 に答える