问题描述
|
我有一个动态创建的表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ѭ就可以使用。