Home  >  Article  >  Web Front-end  >  The relationship between chain operations and hover in jquery - a detailed explanation of the next keyword

The relationship between chain operations and hover in jquery - a detailed explanation of the next keyword

黄舟
黄舟Original
2017-06-26 11:15:381654browse

$("p").css("color","red").addClass("hehe")

This is a very Ordinary chain operations, changing colors, and adding a style "class".

It feels like the chain operation can only be for yourself, but it is not the case.

$(".ti").click(
function( ){
$(this).css("color","red").next(".pcontent").css("display","block");
}
)

This chain operation does 2 things for two different elements.

Clicking on the element whose className is ti will add a class pcon to itself, and then set the display of the element whose class value is pcontent to block.

Note that if you want to operate other elements, you must add the keyword next, otherwise an error will be reported, and next will tell jquery that you want to operate other elements. elements.

And hover in css, a:hover b { color: red }, this is a typical hover a element and then give the b element Writing to increase the effect.

It’s really not easy for these two, they always think about others.

The above is the detailed content of The relationship between chain operations and hover in jquery - a detailed explanation of the next keyword. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn