Slashdot Mirror


User: Octayn

Octayn's activity in the archive.

Stories
0
Comments
1
First seen
Last seen
Profile
(view on slashdot.org)

Comments · 1

  1. Re:Going down in flames on Ask Slashdot: Making JavaScript Tolerable For a Dyed-in-the-Wool C/C++/Java Guy? · · Score: 1

    var hideables = document.getElementsByClassName('hideable');
    var controlStamp = document.getElementById('showhidecontrol').cloneNode(true);
    controlStamp.removeAttribute('id'); /* Let's not have multiple elements with the same id, mmkay? */
    for (var i = 0; i < hideables.length; i++) {
        var hideControl = controlStamp.cloneNode(true);
        hideControl.addEventListener('click', function () { hideables[i].classList.toggle('hidden'); });
        hideables.parentNode.insertBefore(hideControl, hideables[i]);
    }
    /* With a NodeList.forEach, this code becomes less ugly. */