简体   繁体   中英

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 ?

Try this,

Live Demo

$("label[for]")​

试试这个: $('label[for]')如果你不知道什么是等于for

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM