I can't add a class via jQuery with elements inside <ion-nav-buttons>


#1

Hello guys, I’m trying to add a class when I click on the button:

<script>

$(’.test’).on(‘click touchstart’,function(hide) {
$(‘html’).addClass(‘menu-active’);
});

<ion-nav-buttons side="right">
<a class="test" href="">CLICK</a>
<button class="search-btn button icon ion-ios-search-strong"></button>
</ion-nav-buttons>

This jQuery works normally if I put the anchor before the ion-nav-buttons tag.

How can I solve it? Thanks, Lucas.


#2

try this

<ion-nav-buttons side="right">
<a class="test" onclick="menuActive();">CLICK</a>
<button class="search-btn button icon ion-ios-search-strong"></button>
</ion-nav-buttons>

<script>
function menuActive(){
    $('html').addClass('menu-active');
}
</script>

#3

Thanks, it worked! :smile: