You might want to rethink this approach. This could cause a lot of performance issues if you have duplicated widgets on a page simply to have a "global" class to hide or show the elements by.
You might look at letting breakpoints in your css handle this work. Or do some additional work in your widget to display content twice while only getting it once.