html - jquery change custom attribute status -
i'm trying change custom attribute , having no luck. missing silly?
html:
<div class="favorite" status="off">☆</div>
jquery:
$(".favorite").click( function(){ var currentvalue = $(this).attr("status"); if(currentvalue == "off"){ $(this).html("★"); $(this).attr("status") = "on"; }else if (currentvalue == "on"){ $(this).html("☆"); $(this).attr("status") = "off"; } } );
i can change star filled in, status never changes "on". missing?
thanks!
you need use setter version of .attr()(pass value set second argument).
$(this).attr("status", 'on')
Comments
Post a Comment