How to update material design lite badge count

119 views Asked by At

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.

1

There are 1 answers

0
James Gitonga On BEST ANSWER

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