Tony
Tony

Reputation: 12695

jQuery - Selectors for an element with a specific attribute

on my page I have many label tags. Some of them has the for attribute. How should be the jQuery's selector of that label's ?

Upvotes: 0

Views: 51

Answers (3)

Danil Speransky
Danil Speransky

Reputation: 30453

Try this: $('label[for]') if you don't know what is equal to for

Upvotes: 3

Adil
Adil

Reputation: 148110

Try this,

Live Demo

$("label[for]")​

Upvotes: 3

zessx
zessx

Reputation: 68790

A selector like this one will be helpful :

$('label[for="foo"]').css('color', 'red);

EDIT after comment :

To select all labels without knowing the for value :

$('label[for]').css('color', 'red);

Upvotes: 1

Related Questions