javascript - Add an if statement to change css of certain item -
i have created website , within website there list, user can insert items, info user inputs saved database, inside table have 'id', 'content'(which to-do item) , 'status' have put status in here want user able click done, partially done or not done, values 1,2 , 3.
// update list view (var i=0; i< res.length; i++){ $("<li/>", {"id": res[i].id, "text": res[i].content + res[i].status}).appendto(todo.list); // extend width if msg long if(res[i].content.length >= 35){ $('#'+res[i].id).css("height","50px");
the to-do list in javascript, if statement if status 1 turn green, , similar other two, different colours, having trouble getting code correct. thanks.
all need add class li item, in css target class different colour:
$("<li/>", {"id": res[i].id, "text": res[i].content + res[i].status, "class": 'status-' + res[i].status}).appendto(todo.list);
then in css:
.status-1 { color: red }; .status-2 { color: green };
etc (depends if it's color of text or background)
thanks
Comments
Post a Comment