How to to make tooltip appear and disappear by pressing the same button

I am trying to make my tooltip appear and disappear by click on the same button. Like I want to click on the share icon, so the tooltip appear and the click it the second time, and the tooltip is gone and the page is back to the previous state. I tried many ways, but it is still not working.

I have tried to clear the previous state, or use removeEventListener. I am not sure how I can do two different function with the same eventListener on the same button.