jquery使用css函数设置背景色无效解决办法
外部的css样式为:
#imageArea{
width: 200px;
height: 300px;
background-color: #eee !important;
}
通过 以下代码来修改其背景色是无效的
$("#imageArea").css("background-color", "#444444")
$("#imageArea").css("background-color","#444444 !important");
查阅资料得要想修改 div 的背景色(其他样式也一样),可以通过如下这种方式:
$("#imageArea").css("cssText", "background-color:#444444!important");
如需修改多个样式,可以使用以下方法:
$("#imageArea").css("cssText", "height:480px !important; overflow:scroll !important");
备注:
cssText 属性,会把先前的 css 值全部给覆盖掉,为了保留先前其他的样式,可以把现有样式赋值给cssText,像比如要保留width属性,当然cssText也可以链式设置样式:
var cssText = $("#imageArea").attr("style") + ";width:200px !important;";
$("#imageArea").css("cssText": cssText);
其他更多cssText应用请参考cssTex资料
原文链接:https://blog.csdn.net/kirinlau/article/details/87696436
jquery使用css函数设置背景色无效解决办法的更多相关文章
- 设置placeholder无效解决办法
一.设置placeholder的方法 placeholder属性用来设置控件内部的提示信息 <input type="text" placeholder="请输入用 ...
- jquery的ajax()函数传值中文乱码解决方法介绍
jquery的ajax()函数传值中文乱码解决方法介绍,需要的朋友可以参考下 代码如下: $.ajax({ dataType : ‘json', type : ‘POST', url : ‘http: ...
- agruments应用——求出函数参数的总合&&css函数——设置/读取对象的属性&&当前输入框高亮显
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- IDEA Spring-boot-devTools 无效解决办法二
转载地址:Intellij IDEA 使用Spring-boot-devTools无效解决办法 相信大部分使用Intellij的同学都会遇到这个问题,即使项目使用了spring-boot-devtoo ...
- HTTP 错误 500.19 请求的页面的相关配置数据无效 解决办法
"HTTP 错误 500.19 请求的页面的相关配置数据无效" 解决办法 HTTP 错误 500.19 - Internal Server Error无法访问请求的页面,因为该 ...
- iOS 发布证书提示 此证书的签发者无效 解决办法
1. 打开钥匙串 查看发布证书 都是提示 此证书的签发者无效 解决办法 : 2. 到了 第 4 步骤 再去 查看 发布证书 就会 显示 此证书有效 3. 如果还不可以 就 把 Apple W ...
- MyEclipse的JQuery.min.js报错红叉解决办法
MyEclipse的JQuery.min.js报错红叉解决办法 1.选中报错的jquery文件"jquery-1.2.6.min.js".2.右键选择 MyEclipse--> ...
- 在vue中使用 layui框架中的form.render()无效解决办法
下面简单介绍在vue中使用 layui框架中的form.render()无效解决办法. 原文地址:小时刻个人技术博客 > http://small.aiweimeng.top/index.php ...
- WebStorm在Font设置FontSize无效解决方法
我的WebStorm设置了主题.所以直接在File-Settings-Editor-Font设置了无效.它会提醒你要在主题里面改.主题在哪里呢 找到File-Settings-Editor-Color ...
随机推荐
- SpringBoot+MyBatis+PageHelper分页无效
POM.XML中的配置如下:<!-- 分页插件 --><!-- https://mvnrepository.com/artifact/com.github.pagehelper/pa ...
- PyQt5打印机
1.打印机操作(打印默认文本里面的内容)from PyQt5 import QtGui,QtWidgets,QtPrintSupportfrom PyQt5.QtWidgets import *imp ...
- WinForm开发(5)——DataGridView控件(3)——DataGridView控件操作
一.禁止用户改变DataGridView的列宽.行高.列头高度 1.// 禁止用户改变DataGridView1的所有列的列宽 DataGridView1.AllowUserToResizeColum ...
- spark报错 java.lang.NoClassDefFoundError: scala/xml/MetaData
代码: 报错信息: java.lang.NoClassDefFoundError: scala/xml/MetaData 原因:确失jar包 <dependency> <groupI ...
- Feign代理必须加value否则启动失败
Feign代理必须加value否则启动失败 @RequestParam(value=”xxx”)
- 谈一谈并查集QAQ(上)
最近几日理了理学过的很多oi知识...发现不知不觉就有很多的知识忘记了... 在聊聊并查集的时候顺便当作巩固吧.... 什么是并查集呢? ( Union Find Set ) 是一种用于处理分离集合的 ...
- org.springframework.data.redis.RedisConnectionFailureException
org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested ...
- python集合操作方法详解
前言 说集合之前,我们先说一个小例子,假设某公司有五个人喜欢打篮球,五个人喜欢打游戏,问即打游戏有打篮球的人都有哪些? play_basketball = ['a','b','c','d','e'] ...
- 2.1.1Remove Duplicates from Sorted Arr
/* 题目:2.1.1 Remove Duplicates from Sorted Array Given a sorted array, remove the duplicates in place ...
- Mac旧机「焕」新机过程记录
一.首先我做了非硬件上的优化处理,在升级到10.14之前还是挺管用的.但是为了使用最新的iOS SDK,升级到10.14以后,已经不管用了. 1.设置->通用 将动画相关的选项去掉. 2.设置- ...