Hello everyone, I would like to ask, I have a paragraph of text, there are many
I now set a separate class for the first
, using the first-child method Let's set the first
.
But now I want to set the style for the second paragraph, or all the remaining paragraphs. How to set it? What method to use.
I want to implement it like this. The style of the first p is class1, and the styles of the remaining p are all class2.
Does anyone here know how?
p.className("class2");
Set the class separately for the first
, using first-child This method is used for the first
What about the other p? How to set the style?
content
The other p is
content
<!doctype html><html><head><meta charset="gb2312"><title>无标题文档</title><style type="text/css">p:first-child { background-color:#CCC}p { background-color:#ABC}</style></head><body><p>1</p><p>2</p><p>3</p><p>4</p></body></html>
is set like this. After running, look at the source code
or
There is no
, my js cannot perform some operations. Please help me upstairs. Help, I’ll give you extra points
<html><head><meta charset="gb2312"><title>无标题文档</title><style type="text/css">.p_detail { background-color:#CCC}.p_excerpt { background-color:#ABC}</style><script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script><script type="text/javascript">$(document).ready(function(e) { $("p:first-child").addClass("p_detail") $("p:not(:first-child)").addClass("p_excerpt")});</script></head> <body><p>1</p><p>2</p><p>3</p><p>4</p></body></html>