[英]CSS Remove or rename a class on first-child
I have a table TD which is created dynamically. 我有一个动态创建的表TD。 All the TDs created have a CLASS.
创建的所有TD都有一个CLASS。 I have set the first-child Display to NONE.
我已将第一个子显示设置为NONE。 I just need to remove or rename this class just on the first child.
我只需要在第一个孩子上删除或重命名这个类。 Does anyone have any ideas on how I could do this please?
有没有人对我如何做到这一点有任何想法?
Thanks 谢谢
$('table td:first').removeClass('className')
要么
$('table td:first').toggleClass('className')
$(".tdClass").get(0).className = "newClassName"
Should do what you want. 应该做你想做的。 or
要么
$($(".tdClass").get(0)).removeClass("tdClass");
From the jQuery documentation - http://api.jquery.com/first-child-selector/ 来自jQuery文档 - http://api.jquery.com/first-child-selector/
$(".myTable TD:first-child").removeClass("old-class-name").addClass("new-class-name");
or 要么
$(".myTable TD:first-child").attr("class", "old-class-name");
$(#tableid td:first-child').removeClass('oldClass').addClass('newClass');
will work, provided that you substitute to correct id for #tableid
. 只要您替换
#tableid
正确ID,它#tableid
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.