12个class=month,css怎么修改当前月份的样式,不使用jq

WBOY
Release: 2016-06-23 13:38:32
Original
1052 people have browsed it

 


     
          一月
            二月
            三月
        
        
           四月
             五月
              六月
          
          
              七月
                八月
                九月
         
     
                十月
                十一月
                  十二月
         
 
比如当前月份3,通过

   css代码修改3月份的背景色
   


回复讨论(解决方案)

我在

一月里面加了个value="1"
然后css里面写.month[value="1"]{
css样式}
出来了  写些大家

首先用js获取这个tbody下的td,然后each,设置下标标识,判断当前下标,如果当前月份和这个下标相等,那么就设置样式,不想等去掉样式,伪代码:

var i = 0;
document.getElementsByTagName("tbody")[n].childNode("td").each(function(){
    ++i;
    if (i == currentMonth) {
        this.css 加上
    }
    else {
        this.css 干掉
    }
});

好久没用js忘记具体写法了

用js会闪一下(js后加载)  直接css的话就不会闪   

这个就没办法了,因为网页加载有快慢,当没有加载完毕时候,总会出现这个东西,你默认时候不要给任何td加当前样式,这样会好一些,不影响使用

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!