Reputation: 49384
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
Upvotes: 3
Views: 8677
Reputation: 10572
$(".tdClass").get(0).className = "newClassName"
Should do what you want. or
$($(".tdClass").get(0)).removeClass("tdClass");
Upvotes: 1
Reputation: 5259
$(#tableid td:first-child').removeClass('oldClass').addClass('newClass');
will work, provided that you substitute to correct id for #tableid
.
Upvotes: 0
Reputation: 6255
$('table td:first').removeClass('className')
or
$('table td:first').toggleClass('className')
Upvotes: 9
Reputation: 337560
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");
Upvotes: 0