Reputation: 1306
data-record-key
is added to all of my table rows. The value of this attribute increments. When a user adds a row, that row is dynamically added with ajax. I want to change the color of that row but can't figure out how to do that.
This is what that attribute looks like:
data-record-key="31"
$('#test').find('.data-record-key').val('31')
.css("cssText", "background-color:#"+ data.record.myColor +" !important;");
Upvotes: 0
Views: 58
Reputation: 79830
Try using attribute equals selector and apply the style,
$('tr[data-record-key=31]').css('backgroundColor', '#' + data.record.myColor); //no need !important
Upvotes: 1
Reputation: 25159
Use an attribute selector:
$("#test").find('[data-record-key=31]').css("cssText", "background-color:#"+ data.record.myColor +" !important;");
Upvotes: 0