如何使用jQuery更改控件的背景颜色? [英] How to change the background color of a control using jQuery?

查看:168
本文介绍了如何使用jQuery更改控件的背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在网页上有一组类似的控件,我想更改单击控件的背景。当单击该组的另一个控件时,单击的控件应该具有更改的颜色,并且之前的控件应该重新获得其颜色。我可以实现这个吗?

Suppose I have a set of similiar control on a web page and I want to change the background of the control clicked. when another control of the group is clicked then the clicked control should have the changed colour and the previous control should regain its color. Haw can I achieve this?

推荐答案

点击 http: //jsfiddle.net/shemeemsha/7pm6g2dc/ [ ^ ]



简单代码..您可以使用此方法更改任何控件的背景颜色..
Click http://jsfiddle.net/shemeemsha/7pm6g2dc/[^]

Simple code.. You can use this method for changing background color of any control ..


在您的创建类中风格如波纹管

.color

{

bgcolor =#E6E6FA;

}

和bellow条件添加该类
create class in your style like bellow
.color
{
bgcolor="#E6E6FA";
}
and bellow condition to add that class


(#yourID)。addClass(color);
("#yourID").addClass( "color" );


这篇关于如何使用jQuery更改控件的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆