猫咪最喜欢的三件东西:
- 猫薄荷
- 激光笔
- 千层饼
猫咪最讨厌的三件东西:
- 跳蚤
- 打雷
- 同类
id
属性,你可以做一些很酷的事情,例如,就像 class 一样,你可以使用 CSS 来设置他们的样式
可是,id
不可以重用,只应用于一个元素上。同时,在 CSS 里,id
的优先级要高于class
,如果一个元素同时应用了class
和id
,并设置样式有冲突,会优先应用id
的样式。
选择id
为cat-photo-element
的元素,并设置它的背景样式为green
,可以在style
标签里这样写:
```css
#cat-photo-element {
background-color: green;
}
```
注意在style
标签里,声明 class 的时候必须在名字前插入.
符号。同样,在声明 id 的时候,也必须在名字前插入#
符号。
cat-photo-form
id属性的form
表单的背景颜色设置为green
。
form
元素的 id 为cat-photo-form
。'
testString: assert($("form").attr("id") === "cat-photo-form");
- text: 'form
元素应该含有background-color
css 属性并且值为 green
。'
testString: assert($("#cat-photo-form").css("background-color") === "rgb(0, 128, 0)");
- text: '确保form
元素含有id
属性。'
testString: assert(code.match(/form
元素上添加其他class
属性或者style
行内样式。'
testString: assert(!code.match(/