在活动选项卡上更改父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