Accepted answer

this in callback refers to the chart itself. Buttons are stored in chart.exportSVGElements array. So, here is the solution:

                toggleButton: {
                    text: 'ON',
                    onclick: function () {
                        var button = this.exportSVGElements[0], // 0 = text element, 1 = rect button
                            $button = $(button.element); // in "element" stored is reference to the DOM object
                            text = $button.text() == "ON" ? "OFF" : "ON";

                            text: text

Note using Highcharts built-in method attr() for updating text, not jQuery's text().


For Highcharts 4.2.3+ use the solution below:

The only difference is how to get button in jQuery: $button = $(button.element.lastChild).

Related Query

More Query from same tag