Select the number of child elements under the parent element of the specified type (p):
Instance:
<! DOCTYPE html>;} Html{font:15px/1.2em ' Courier New '; color: #666;} div > *{margin:10px 0; cursor:pointer;} #demo {width:750px;margin:75px Auto;} button{padding:5px 15px;border:0;outline:none;margin-top:-5px;border-radius:2px;font:400 12px/1.2em ' Courier New ';} . active{background-color:yellow;transition:. 3s;} . Hover{background-color:red;transition:. 3s} p{text-indent:8px;}</style><script type= ' Text/javascript ' >/** Overview Select Nth in child elements that belong to a parent element and have the same label name. Because of the implementation of jquery: nth-is strictly from the CSS specification, the N value is "1-indexed", that is, counting from 1 onwards. For all other selector expressions such as: eq () or: Even, jquery follows the count of JavaScript's "0 index". */ $(function(){ $("Span:nth-of-type (2)"). AddClass (' hover ')); });</script>
[jquery selector: Nth-of-type ()] Select the number of child elements under the parent element of the specified type (p)