使用JavaScript更改CSS(jQuery)
Change CSS with JavaScript (jQuery)
我有一个CSS"按钮",它覆盖了一些表行。每次单击它,都会显示下一行。显示最后一行后,文本将更改为DONE!下面的脚本实现了这一切,并且正在发挥作用。
<script type="text/javascript">
$(document).ready(function () {
var last = $('tbody tr:hidden').length;
if (last > 0) {
$("#nextStep").click(function () {
var x = $("tbody tr:hidden:first");
console.log(x);
console.log(last);
$("tbody tr:hidden:first").show();
last = $('tbody tr:hidden').length;
if (last == 0) {
$("#nextStep").html('DONE!');
$("#nextStep").css('cursor', 'default');
}
});
}
});
我想添加以下内容:当文本更改为DONE!时!,我还想改变背景的颜色。应用于此按钮的CSS是…
.show_next_button {
-moz-box-shadow:inset 0px 1px 0px 0px #bbdaf7;
-webkit-box-shadow:inset 0px 1px 0px 0px #bbdaf7;
box-shadow:inset 0px 1px 0px 0px #bbdaf7;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #79bbff), color-stop(1, #378de5) );
background:-moz-linear-gradient( center top, #79bbff 5%, #378de5 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#79bbff', endColorstr='#378de5');
background-color:#79bbff;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #222529;
//display:inline-block;
//display:table-cell;
color:#ffffff;
font-family:arial;
font-size:25px;
font-weight:bold;
//padding-left:20%;
//padding-right:20%;
padding-top:50px;
padding-bottom:50px;
text-align:center;
text-decoration:none;
text-shadow:1px 1px 0px #4c6d8f;
}
.show_next_button:hover {
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #378de5), color-stop(1, #79bbff) );
background:-moz-linear-gradient( center top, #378de5 5%, #79bbff 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#378de5', endColorstr='#79bbff');
background-color:#378de5;
cursor:pointer;
}
.show_next_button:active {
position:relative;
top:1px;
}
关于我该如何做到这一点,有什么想法吗?
创建一个具有新背景色的类a,然后将其添加到
.completed-step {
background-color: pink;
cursor: default;
}
// replace the call to '$("#nextStep").css('cursor', 'default');'
$("#nextStep").addClass("completed-step");
这是一个例子http://jsfiddle.net/ED4Zt/1/
相关文章:
- 每个选择器的Jquery css颜色都在变化,但字体大小却没有变化
- 自定义Jquery css下拉菜单问题
- jQuery css可见性在load方法中不起作用
- PNG图像被覆盖,但每个图像都有一个链接可以更改,每次一个-Javascript/jQuery/CSS
- Jquery CSS背景图像旋转
- 使用jQuery.css()方法时,是否需要转义任何字符
- 将jQuery.css()与变量一起使用
- 如何在jQuery.CSS()方法中为所有浏览器编写CSS代码
- 使用 js/jQuery/css 在重力形式中覆盖 !important
- 投资组合扩展器宽度 - Jquery CSS
- jQuery .css body opacity
- 当到达屏幕顶部时,jquery/css转换
- 如何防止文本区域在打字和进入页面底部时跳舞?:JQuery/CSS
- 在没有特定属性的情况下使用jQuery.css()
- 如何在HTML+jQuery+CSS中显示弹出窗口
- jQuery css"点击“;不会'更改日历中选定的月份后无法工作
- jQuery .css() 返回像素而不是百分比
- jquery css没有'我的情况不太好
- Jquery/CSS:全尺寸背景图像
- jquery.css()中的变量