Home > Web Front-end > JS Tutorial > body text

What is the difference between jquery attr and css

coldplay.xixi
Release: 2020-11-30 16:19:41
Original
2652 people have browsed it

The difference between jquery attr and css: 1. Attr obtains and modifies the attributes of the element, such as the src attribute and alt attribute of img; 2. CSS obtains and modifies the attributes in the style, that is, attributes in style.

What is the difference between jquery attr and css

The difference between jquery attr and css:

The difference between attr and css

  • attr(): What is obtained and modified is the attribute of the element, such as the src attribute and alt attribute of img, the href attribute of a link, etc.

  • css(): What is obtained and modified is the attributes in the style, that is, the attributes in the style.

$("#test").css("display", "block");//第1种方法
Copy after login
$("#test").attr("style", "display:block;");//第2种方法
Copy after login
$("#test").show();//第3种方法
Copy after login

Be careful not to write

$("#test").attr("display", "block");
Copy after login

Related free learning recommendations: JavaScript (video)

The above is the detailed content of What is the difference between jquery attr and css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template