关于js更改样式问题

首先看一下代码:
<div id="divselect">
    <cite>请选择资源分类</cite>
   ....
如果在样式表中定义样式如下:
#divselect cite
{
    height: 24px;
    line-height: 24px;
    display: inline;
    color: #807a62;
    cursor: pointer;
    font-style: normal;
    padding-left: 4px;
    padding-right: 30px;
    border: 1px solid #333333;
    url(".. /p_w_picpaths/up.png") no-repeat right center;
}
.cite-up
{
    height: 24px;
    line-height: 24px;
    display: inline;
    color: #807a62;
    cursor: pointer;
    font-style: normal;
    padding-left: 4px;
    padding-right: 30px;
    border: 1px solid #333333;
    url(".. /p_w_picpaths/up.png") no-repeat right center;
}
.cite-down
{
    height: 24px;
    line-height: 24px;
    display: inline;
    color: #807a62;
    cursor: pointer;
    font-style: normal;
    padding-left: 4px;
    padding-right: 30px;
    border: 1px solid #333333;
    url(".. /p_w_picpaths/xjt.png") no-repeat right center;
}
在Jquery中更改cite对象的背景时,代码如下:
$(“#divselect cite").attr("class", "cite-down");
或者:$((“#divselect cite”)[0].style.background = 'url("../p_w_picpaths/xjt.png") no-repeat right center';
会出现样式没有刷新的情况。
解决方法如下:
1、直接指定cite对象的class
<div id="divselect">
<cite>请选择资源分类</cite>
....
 
2、删除样式"#divselect cite"
3、JS代码不变。

分享标题:关于js更改样式问题
浏览地址:https://www.cdcxhl.com/article20/igsjjo.html

成都网站建设公司_创新互联,为您提供外贸建站网站设计公司虚拟主机网站建设外贸网站建设软件开发

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都app开发公司