Home  >  Article  >  Web Front-end  >  JQuery CSS style control study notes_jquery

JQuery CSS style control study notes_jquery

WBOY
WBOYOriginal
2016-05-16 18:49:191027browse

Not much to say about jQuery. This is a function library of JS that is relatively commonly used. Today we will summarize the three operations of jQuery for css
$(selector).css("name","value" )
$(selector).css({properties})
$(selector).css(name)
$(selector).css("name","value") is given for all elements CSS property setting value:
Look at the code I just wrote below

Copy the code The code is as follows:




The corresponding html can be written as

When the background of this text turns red, the size will become twice as large





The following is the supplementary test code as follows
Copy code The code is as follows:





无标题文档






我会变颜色哦

添样式
去除样式
变样式
多点几下变样式
变色



1.addClass(class)
描述:为选择的元素集合添加指定样式。
2.removeClass([class])
描述:为选择的元素集合删除指定样式。
3.toggleClass(class)
描述:替换选择的元素集合样式。备注下,如果当前元素的样子已经为class时,将会去除该样式,相当于addClass与removeClass的结合方法。
4.toggleClass(class, switch)
描述:与上一个方法类似,区别就是多加了个switch判断,当switch值为true时,对进行样式的改变
5.css(styleName,value)/css(styleName)/css({value})
描述:css(styleName,value)用于设置当前元素的styleName样式属性值为value,css(styleName)用于获取当前元素的styleName样式属性值,而css({value})而为另一种设置样式属性值的方法,具体用法参考例子^^,因为跟element.attr的用法类似所以在这就不详细说明了
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
Previous article:jquery Three ways to set disabled elements to enabled_jqueryNext article:jquery Three ways to set disabled elements to enabled_jquery

Related articles

See more