点击时可以更改jquery- div颜色 [英] jquery- div color to be changed upon div click
问题描述
hi..i有一个要求:一个页面有三个div。使用div点击要更改的背景颜色,并将其内容显示在一个范围内。
i尝试如下:
hi..i hav a requirement that : a page has three divs.Upon div click its background color to be changed and its content to be displayed in a span.
i tried as below:
("#div").click{
$(this).removeclass(x);
$(this).addclass(y);
$(#span).html("content");
}
但是这不是在点击另一个div后恢复div原始颜色
Plz帮助我
如果我对每个div有相同的课程没有问题...但我的要求是
i hav每个div的不同类...如何解决这个问题...帮助我
But this is not restoring divs original color after another div is clicked
Plz help me
if i has same class to each div there is no issue...but my requirement is
i hav different class for each div...how to solve this ...help me
推荐答案
( this )。removeclass(x);
(this).removeclass(x);
( this )。addclass(y);
(this).addclass(y);
(#span).html( content);
}
(#span).html("content"); }
但是这不是在点击另一个div后恢复div原始颜色
Plz帮助我
如果我对每个div有相同的课程没有问题...但我的要求是
i hav每个div的不同类...如何解决这个问题......帮助我
But this is not restoring divs original color after another div is clicked
Plz help me
if i has same class to each div there is no issue...but my requirement is
i hav different class for each div...how to solve this ...help me
这篇关于点击时可以更改jquery- div颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!