在活动选项卡上更改父Div背景的颜色 [英] Changing parent Div background color on active tab
本文介绍了在活动选项卡上更改父Div背景的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图找出如何在单击选项卡时更改父div容器的背景颜色.我想拥有它,以便在选项卡处于活动状态时将一个类添加到父div.每个活动标签都会为父级添加不同的背景颜色.
I am trying to figure out how to change the parent div container background color when clicking a tab. I want to have it so that when a tab is active it adds a class to the parent div. Each active tab would add different bg color to the parent.
这就是我想做的.
推荐答案
我在您的控制台中尝试过,请检查
I tried it in your console, check this
var colors = ["red", "black", "yellow"];
jQuery(document).ready(function() {
jQuery(".vc_tta-tabs-list > li").on("click", function() {
jQuery(".grve-section").css("background", colors[jQuery(this).index()])
})
})
$
未在您的代码中分配,这就是为什么我在此处更改为jQuery
$
is not assigned in your code, that's why I changed to jQuery
here
这篇关于在活动选项卡上更改父Div背景的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文