How to periodically check if I have a link on the html page or not?

How to periodically check if I have a link on the html page or not?

I have a DIV in my html page. and within the DIV I have a link that shows up when I am online.

Any way to hide and show the DIV depending on if anyone is online or not? like only show DIV when online link is active?

How can I periodically poll using an AJAX call or Jquery every n minutes or seconds to check if someone was online and update the CSS class accordingly based on if the function returned true or not and make DIV visible accordingly?