如何将CSS分配给具有两个或多个选择器的JavaScript

问题描述

我正在尝试在JavaScript的帮助下分配很大的html和css代码块。该代码在白天模式下可以正常工作,但是在夜间模式下,我对此有一点疑问。启用夜间模式后,给定containerimg不会改变颜色和其他值。我犯了什么错误

https://codepen.io/vkdatta27/pen/qBNZagr

解决方法

在您的方法中使用2个参数将不起作用。

# Converting date column strings to date objects
df['endDate'] = pd.to_datetime(df['endDate'],format='%Y-%m-%d')
df['startDate'] = pd.to_datetime(df['startDate'],format='%Y-%m-%d')
# Setting endDate column as my index
df.set_index("endDate",inplace= True)
# Creating daily dates range between start and end dates from the df
dates_range = pd.date_range(start='2020-10-26',end='2025-10-27')
idx = pd.DatetimeIndex(dates_range)
df = df.reindex(idx)

请参阅:getElementsByClassName() with two classes

在任何情况下,您的做法都是错误的做法,请像这样不断更改dom,因为它会减慢浏览器渲染重绘的速度。相反,我建议您放入样式表并分批分发到dom。

$('input.parent').on('change',function(){
    var id = $(this).val();
    if($(this).is(':checked')){
        $('.child[data-rowid |="'+id+'"]').attr('checked',true);
    }else{
        $('.child[data-rowid |="'+id+'"]').attr('checked',false);
    }
})