user3649067
user3649067

Reputation: 237

Issue On Adding Class to Specific <td> with a Class

Can you please take a look at This Demo and let me know why I am not able to add .sale class to last columns of table which has a class of .item using .find()

$(function () {
    $('td:nth-child(6) ,td:nth-child(7)').find("item").addClass("sale");
});

Upvotes: 0

Views: 21

Answers (1)

Bojan Petkovski
Bojan Petkovski

Reputation: 6933

You are missing a dot in item. It should be

$(function () {
    $('td:nth-child(6) ,td:nth-child(7)').find(".item").addClass("sale");
});

http://jsfiddle.net/poz1f1a3/2/

The css

.item {
    background-color: grey;
    height:45px;
    width:65px;
}
.sale {
    background-color: yellow;
}

Upvotes: 4

Related Questions