javascript - How to add class to all TD - Stack Overflow

I am using jQuery with addClass to add class to some elements.But for some reason not all "td&quo

I am using jQuery with addClass to add class to some elements. But for some reason not all "td" get the class assigned (the ones with the .currentmonth).

$("td").addClass("aaawwwasdsad");

/

I am using jQuery with addClass to add class to some elements. But for some reason not all "td" get the class assigned (the ones with the .currentmonth).

$("td").addClass("aaawwwasdsad");

https://jsfiddle/wheelq/7Lesommm/

Share Improve this question asked Feb 14, 2016 at 20:23 meso_2600meso_2600 2,1366 gold badges26 silver badges50 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

Because other Javascript functions run later.

Look : https://jsfiddle/p9kogsmL/14/

Define it into the end of calendar function :

     ...

        document.getElementById("calendar").innerHTML += calendarTable;
        $("td").addClass("aaawwwasdsad");
      }

If you want to add a class to all td ,you have to use each loop. here is an example:

$("td").each(function(){
   $(this).addClass("aaawwwasdsad");
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745252518a4618763.html

相关推荐

  • javascript - How to add class to all TD - Stack Overflow

    I am using jQuery with addClass to add class to some elements.But for some reason not all "td&quo

    2小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信