16
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CSSで複数の属性セレクタを指定する

Last updated at Posted at 2015-10-16

CSSで属性セレクタを指定する。

属性が一つの場合

div[data-color="red"]{
    background-color: red;
}

属性が2つの場合

div[data-color="red"][data-size="small"]{
    background-color: red;
    font-size: 10px;
}

JSでも使える

var colorVal = 'red';
var sizeVal = 'small';

$('div[data-color="' + colorVal + '"][data-size="' + sizeVal + '"]').show();

16
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?