div设置多个class

在 HTML 中,一个 class 值中可能包含一个词列表,各个词之间用空格分隔。例如,如果希望将一个特定的元素同时标记为重要(important)和警告(warning),就可以写作:
<p class="important warning">
This paragraph is a very important warning.
</p>
这两个词的顺序无关紧要,写成 warning important 也可以。
我们假设 class 为 important 的所有元素都是粗体,而 class 为 warning 的所有元素为斜体,class 中同时包含 important 和 warning 的所有元素还有一个银色的背景 。就可以写作:
.important {font-weight:bold;}
.warning {font-weight:italic;}
.important.warning {background:silver;}  //相当于两个class有相同的样式。

 

其实是一个DIV拥有两个Class 空格并不是一个CLASS,用jquery你只需要$(".import")或 $(".warning")就可将其选定。

posted @ 2015-12-01 09:25  i日出  阅读(7635)  评论(0编辑  收藏  举报