-5

enter image description here

This is what I am trying to achieve, class of the status would changed based on data coming. My JS:

$(document).ready(function () { var cls = 'label-info'; if(data-value == 'Progress'){ cls = 'label-warning'; } else(data-value == 'New'){ cls = 'label-success'; } $('#label').addClass(cos); }); 

My JS:

My Html:

<span id="label" class="label label-sm " data-value = "{{ account.status }}"> {{ account.status }} </span> 
2
  • please, share console logs Commented Jul 5, 2016 at 13:54
  • codepen.io/aihowes/pen/bZRxWr Commented Jul 5, 2016 at 14:03

1 Answer 1

0

Change your class variable name

$('#label').addClass(cls); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.