CSS删除或重命名第一个孩子的类

问题描述

| 我有一个动态创建的表TD。 创建的所有TD都有一个CLASS。 我已将第一个孩子的Display设置为NONE。 我只需要在第一个孩子上删除或重命名此类。 请问有人对我该怎么做有任何想法吗? 谢谢     

解决方法

$(\'table td:first\').removeClass(\'className\')
要么
$(\'table td:first\').toggleClass(\'className\')
    ,
$(\".tdClass\").get(0).className = \"newClassName\"
应该做你想做的。 要么
$($(\".tdClass\").get(0)).removeClass(\"tdClass\");
    ,从jQuery文档-http://api.jquery.com/first-child-selector/
$(\".myTable TD:first-child\").removeClass(\"old-class-name\").addClass(\"new-class-name\");
要么
$(\".myTable TD:first-child\").attr(\"class\",\"old-class-name\");
    ,只要您用正确的ID代替
#tableid
,6ѭ就可以使用。     

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...