Using (custom) jQuery data-attributes to retrieve the elements where these icons are displayed, I am successfully changing icons with this working code:
<i class="glyphicon glyphicon-check" data-year="2014" data-flag_check="1"></i>
...
<script>
...
$('i[data-year="2014"]').removeClass('glyphicon-check').addClass('glyphicon-unchecked');
But, if I attempt to replace the constant 2014 with a variable, my code stops working.
var yearIn = "2014";
$('i[data-year=yearIn]').removeClass('glyphicon-check').addClass('glyphicon-unchecked');
Is it possible to perform this operation with a variable?
If so, what is wrong in my syntax?