user745235
user745235

Reputation:

jQuery - Find element with rel attribute

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();

Upvotes: 20

Views: 57415

Answers (3)

Nudier Mena
Nudier Mena

Reputation: 3274

yon can select all elements with href att with this selector

$(document).ready(function()
{

$("[rel]")

});

Upvotes: 2

dku.rajkumar
dku.rajkumar

Reputation: 18568

the exact one

$('i[rel="tooltip"]').tooltip()

Upvotes: 26

js1568
js1568

Reputation: 7032

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

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

Upvotes: 24

Related Questions