Question

I try to build my custom theme, based on "Galleria theme Classic", but I'm straggling to trigger class on my button, I think, I miss something,

   this.addElement('play').appendChild('container','play');
   var g = this;
   this.$('play').text('Play').bind('mouseup', function() {
            g.playToggle();
            g.toggleClass("highlight"); // - This line don't work
});

I get error @TypeError: g.toggleClass is not a function@

Was it helpful?

Solution 2

It looks like you're calling toggleClass on the wrong element, or the element is not jQuery wrapped (not quite clear from posted code). Try this:

$(g).toggleClass('highlight');

Or this:

g.$('play').toggleClass('highlight');

OTHER TIPS

For reference, element.classList.toggle("classname") is another option.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top