Display badge because of notification from other URL

Hi, suppose I have a menu button, clicking the button displays menu bar in which click event listeners point out to multiple URL. Now I want to show notification badge in both menu button and menu-item from which it is coming.

How can I plan a strategy to execute this kind of function?