I have a menu inside a div, which is closed/hidden by default. it opens when I click on it, with adding the class open to it.
<ul class="mydropdown-menu">
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ul>
<ul class="mydropdown-menu">
change to <ul class="mydropdown-menu open">
when menu is visible.
since this happens dynamically, can't use usual jquery's hasClass
to determine whether it's there.
I heard about Mutation Observer and I tried few examples found on internet, but nothing seems to work out for me.
Can someone help me to achieve this?
I just need to know everytime my menu's ul
element opens up/adds the open class to it, using mutation observers. how can I do this with jQuery?