一、div设置多个class
在 HTML 中,一个 class 值中可能包含一个词列表,各个词之间用空格分隔。例如,如果希望将一个特定的元素同时标记为重要(important)和警告(warning),就可以写作:
1 | <p class="important warning"> |
这两个词的顺序无关紧要,写成 warning important 也可以。
我们假设 class 为 important 的所有元素都是粗体,而 class 为 warning 的所有元素为斜体,class 中同时包含 important 和 warning 的所有元素还有一个银色的背景 。就可以写作:
1 | .important {font-weight:bold;} |
其实是一个DIV拥有两个Class 空格并不是一个CLASS,用jquery你只需要(“.warning”)就可将其选定。