How to disable HTML attributes with js?

I have a menu with hover dropdown menus. On mobile I want to disable the href attribute so that clicking the link doesn’t redirect, but opens the dropdown. I am currently using removeAttribute() to do that. But the problem is that if the user uses the site in a smaller window which triggers the mobile version and then makes the window bigger I need to add back the href. I could use setAttribute() but then I have to keep track of the links to add them back and I don’t feel like that’s the best solution. Is there a way to just disable the href attribute with js?