简体   繁体   中英

CSS Remove or rename a class on first-child

I have a table TD which is created dynamically. All the TDs created have a CLASS. I have set the first-child Display to 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/

$(".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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM