html - jquery change custom attribute status -


i'm trying change custom attribute , having no luck. missing silly?

html:

    <div class="favorite" status="off">&#9734</div> 

jquery:

    $(".favorite").click(         function(){             var currentvalue = $(this).attr("status");             if(currentvalue == "off"){                 $(this).html("&#9733;");                 $(this).attr("status") = "on";             }else if (currentvalue == "on"){                 $(this).html("&#9734;");                 $(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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -