jquery中的css函数css(name)、css(key,value)、css(properties)、css(key,fn)
2017-08-29 08:51
477 查看
全栈工程师开发手册 (作者:栾鹏)
jquery系列教程2-style样式操作全解
代码如下:
jquery系列教程2-style样式操作全解
jquery通过css函数操作元素样式
jquery的css函数,包括css(name)、css(key,value)、css(properties)、css(key,fn),具体功能如代码中注释。代码如下:
$cr.css("color"); //css(name)读取style样式 $cr.css("color","red"); //css(key,value)设置style样式,等价于cr.style.color="red" $cr.css({'fontSize':'30px','backgroundColor':'#888888'}); //css(properties)同时设置多个样式。在带有-的样式属性中如font-size,添加引号后,可以写成font-size也可以写成驼峰式fontSize if($cr.css("height")==$cr.height()){ //css(key,fn)通过函数计算样式值,height()获取的高度与样式无关,是元素在页面中的实际高度,不带单位。css("height")获取的高度与样式有关,可能会得到auto结果,也有可能得到10px字符串 $cr.height(100); //设置高度为数字,默认单位为px $cr.height("10em"); }
相关文章推荐
- jquery中的attr函数attr(name)、attr(key,value)、attr(properties)、attr(key,fn)、removeAttr
- 属性attr(name|properties|key,value|fn)
- jquery手册学习--属性--attr(name|pro|key,val|fn) --removeAttr(name)
- jquery手册学习--数据缓存--data([key],[value])--removeData([name|list])--jQuery.data(element,[key],[value])
- 在网页中引用js文件、css文件或图片文件时为什么要加上问号+值或key-value
- this class is not key value coding-compliant for the key nameField.'
- 来段代码提提神-Java读取config.properties文件中的key=value
- iOS: setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key name.
- Java,spring程序中实时获取.properties属性key的value
- jQuery 数据缓存data(name, value)详解及实现
- S/Jquery 中怎么定义存储一个类似map中key-value形式的变量,并且怎样动态赋值key和value?
- jquery通过name获取到所有的value并且构造一个数据传到后台
- 把表单转成json,并且name为key,value为值
- jquery如何通过name名称获取当前name的value值
- 根据key从Properties文件中加载指定的value
- jQuery 数据缓存data(name, value)详解及实现
- Jquery-根据标签的name属性,获取其value值。存入对象并且转换为Json数组
- jQuery中data([key],[value])和jQuery.data(element,[key],[value])区别
- jQuery数据缓存data(name, value)详解及实现
- 通过NameValuePairsValueProvider对象来获取指定前缀的Key