如何使用jquery在函数调用中更改多个div的颜色 [英] How to change color of multiple div on function call using jquery

查看:159
本文介绍了如何使用jquery在函数调用中更改多个div的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




第1页的内容

Content of page 1




第2页的内容

Content of page 2




第3页的内容

Content of page 3








我尝试过:



check = function(){

$( #step_wrapper> div)。css(background-color:red);

}







它正在改变所有step_box1的背景颜色,我只想更改所选div的背景颜色。

谢谢



What I have tried:

check= function(){
$("#step_wrapper > div").css("background-color":"red");
}



it is changing background color of all step_box1 ,I want to change background-color of selected div only.
thank you

推荐答案

(#step_wrapper> div)。css(background-color:red);

}







它正在改变所有step_box1的背景颜色,我想改变所选div的背景颜色。

谢谢
("#step_wrapper > div").css("background-color":"red");
}



it is changing background color of all step_box1 ,I want to change background-color of selected div only.
thank you


因为你的代码不清楚它ks就像你用于div元素的选择器的问题。您必须使用正确的选择器并确保该元素存在。否则
As your code is unclear it looks like problem with selector you are using for "div" elements. You have to use proper selector and make sure that element is exist. Otherwise
.css("background-color":"red")

将适用于#step_wrapper内的所有div或什么都不是。



在代码中添加更多细节。

will apply to all "div" inside "#step_wrapper" or to nothing.

Add more detail to your code.


试试这个



try this


这篇关于如何使用jquery在函数调用中更改多个div的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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