
This is my user-list.
I need to change the red circular label.
$("#infoListBox .label").text($("#infoListBox a").length); $("#infoListBox .list").bind("DOMSubtreeModified",function(){ $("#infoListBox .label").text($("#infoListBox a").length); }); When the document loads, get the number on (red) tag and change the label; next, a tag remove (change label from 21 to 20).
I want to improve this code.
My solution in a better way.
function getUserLength(){ return $("#infoListBox .label").text($("#infoListBox a").length); } // user count getUserLength(); $("#infoListBox .list").bind("DOMSubtreeModified",function(){ $("#infoListBox .label").val(getUserLength()); }); I use jade template engine, my jade code below..
div(id='infoListBox').ui.fluid.vertical.menu div.header.item Users a.ui.red.circular.label div.list.item a.item Me a.item 조제우 a.item 장형주 a .item 남중민 a.item Me a.item 조제우 a.item 장형주 a.item 남중민 a.item Me a.item 조제우