jQuery - Get and set CSS classes

jQuery Manipulating CSS

jQuery has several methods for CSS manipulation. We will study the following:

addClass() - Add one or more classes to the selected element

removeClass() - Remove one or more classes from the selected element

toggleClass() - Add/delete class switching operation for selected elements

css() - Set or return style attributes

Style sheet

.important

{

font-weight:bold;

font-size:xx-large;

}


addClass() method

       

标题 1

标题 2

段落1

段落2

文本

You can also specify multiple classes in the addClass() method :

       
文本。
文本。


removeClass() method

       

标题 1

标题 2

段落1

段落2



##toggleClass() method

This method is The selected element performs the switching operation of adding/deleting classes:

       

标题 1

标题 2

段落1

段落2



Continuing Learning
||
php中文网(php.cn)
php.cn欢迎您
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!