I've had a look around but I've not found anything that can really address the issue that I'm having and although I can read and write basic JS I'm still finding it tricky to debug my own problems.
I'm trying to remove a class from an element onclick and for some reason .removeClass isn't working as expected. I'm already using some JS to trigger style changes (also onclick) so I know the element ID and classes are correct.
Trigger Element: #gsbtns1 .vc_btn3-color-grey
Class to remove: .nest-custom-activator
Here is part of my working 'style' JS:
<script>
jQuery('#gsbtns1 .vc_btn3-color-grey').click(function() {
jQuery('#gsbtns1 .vc_btn3-color-grey').css({
'opacity': '0.3',
'cursor': 'auto',
'pointer-events': 'none'
});
});
</script>
Here is a screenshot and text copy of the trigger element in Console:
Console Screenshot:
Console Text:
<div class="vc_btn3-container nest-custom-activator
wpb_animate_when_almost_visible wpb_fadeIn fadeIn vc_btn3-inline
vc_custom_1505915503693 wpb_start_animation animated" id="gsbtns1">
I've tried this JS:
<script>
jQuery('#gsbtns1 .vc_btn3-color-grey').click(function() {
jQuery(".vc_btn3-color-grey").removeClass("nest-custom-activator");
});
</script>
and this JS:
<script>
jQuery('#gsbtns1 .vc_btn3-color-grey').click(function() {
jQuery("#gsbtns1 .vc_btn3-color-grey").removeClass("nest-custom-activator");
});
</script>
Sadly, neither of these are removing the .nest-custom-activator class.
Can anyone help me understand why this isn't working?
