javascripthtmlmaterial-design-lite

How to update material design lite badge count


How can I update the data-badge count on a Material Design Lite badge in javascript? For example, the count of new notifications on a notification badge after fetching the notifications from the database.


Solution

  • Found the solution in Javascript:

    let element = document.getElementById("#yourBadgeId");
    
    element.setAttribute("data-badge" , yourValue);
    
    

    make sure that in the html script, the mdl badge tag should not contain the data-badge attribute