How to change the color of the toggle through javascript?


#1
window.onload = function() {
var color_toggle = 'toggle toggle-';
var letters = ['positive', 'balanced','calm','energized','assertive','royal','dark',];
letters_random = letters[Math.floor(Math.random() * letters.length)];
document.getElementById('toggle-color').className = color_toggle + letters_random; };

If in normal mode, everything is ok:

<label class="toggle">
    <input type="checkbox">
    <div id="toggle-color" class="track">
        <div class="handle"></div>
    </div>
</label>

Have the other way, no way, and now:

<ion-toggle>
</ion-toggle>