Differences between CSS () and addclass () in jquery learning beginners

Source: Internet
Author: User
Getting started with jquery: CSS () and addclass ()
I have been studying jquery in the past two days. I just started to get started. from yesterday, I found a method of addclass. In this tutorial, a method is written like this.
$ (Document). Ready (function (){
$ ("P"). addclass ("red ");
});
However, I did not take this into consideration and thought that red is the specific color of red. Then, when I write an example myself, I define a $ ("p"). addclass ("green ");
After the operation, I did not find any changes in CSS. Today I carefully studied my God. In this example, red is a type that has been defined in CSS, But I mistakenly think it is red color, the reason is that you do not know much about CSS. Then I defined a. Green {color: green;} style in the CSS file. I tried it and it was OK.
For CSS (), this method is defined to set the value of a style attribute among all matching elements,
Example: $ ("P" ).css ("color", "Red"); Prefix: attribute name, followed by specific attribute parameters.
I decided to send all my learned knowledge to my blog, which gave me a little sense of accomplishment ......
Now, continue with my jquery
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.