Js click method how to change the click object dynamically

ideas:

A group of a tags that can be clicked only if they are clicked in order, and cannot be clicked otherwise.
Click in the order from top to bottom. If you don"t click on the A tag in the order, you can"t click on it. You click on the LI tag, and the event is triggered by the li tag. After the previous object is clicked, the disabled of the next A tab will be released, and the click of the LI to which A belongs will also remove
for example: one, two, three, if you do not click the first point, the second will pop up the corresponding prompt, or warning.
N Click N for the click event that releases disabled and li as soon as the page loads. The disabled CLASS of nasty 1 will be released, and so will the click event of the LI to which it belongs.

the code is as follows:

online debugging: https://codepen.io/TtSir/pen/.


  <div id="div1"></div>
  <ul>
      <li class="liProhibited"><a href="-sharp" style="display: block" class="Prohibited"></a></li>
      <li class="liProhibited"><a href="-sharp" style="display: block" class="Prohibited"></a></li>
      <li class="liProhibited"><a href="-sharp" style="display: block" class="Prohibited"></a></li>
  </ul>
<button onclick="aRemoveDisabled()">aRemoveDisabled</button>

</script>
function addLoadListener(fn) {
    if (typeof window.addEventListener != "undefined")
    {
        window.addEventListener("load",fn,false);
    }
    else if (typeof document.addEventListener != "undefined")
    {
        document.addEventListener("load",fn,false);
    }
    else if (typeof window.attachEvent != "undefined")
    {
        window.attachEvent("onload",fn);
    }
    else
    {
        var oldfn = window.onload;
        if (typeof window.onload != "function")
        {
            window.onload = fn;
        }
        else
        {
            window.onload = function() {
                lodfn();
                fn();
            };
        }
    }
}
addLoadListener(nav);
function nav(){
    var initialPage=document.getElementById("initialPage"),
        oA = document.getElementsByTagName("li");
    for (var i = 0; i < oA.length; iPP) {
        oA[i].onclick = function () {
            for (var i = 0; i < oA.length; iPP) {
                oA[i].style.background = "";
            }
            this.style.background = "-sharp676464";
            if(document.getElementById("initialPage")){biological.remove([initialPage]);}
        }
    }
}
function hasClass(ele, cls) {
    return ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
}
function addClass(ele, cls) {
    if (!this.hasClass(ele, cls)) ele.className += " " + cls;
}
function removeClass(ele, cls) {
    if (hasClass(ele, cls)) {
        var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
        ele.className = ele.className.replace(reg, " ");
    }
}
addLoadListener(aAddDisabled);
function aAddDisabled() {
    var disabledGroup=document.getElementsByClassName("Prohibited");
    for(var i=0;i<disabledGroup.length;iPP){addClass(disabledGroup[i],"disabled");disabledGroup[i].addEventListener("click",aClick);}
}
function aClick() {
    console.log("A");
}
function aRemoveDisabled() {
    removeLiRemind();
var disabledGroup=document.getElementsByClassName("Prohibited");
    var liProhibitedGroup=document.getElementsByClassName("liProhibited");
    for(var l=0;l<liProhibitedGroup.length;lPP){liProhibitedGroup[l].addEventListener("click",li1)}
    var order=0;
    //self.setInterval(function () {console.log(order)},3000);
    if(order ===0 ){removeClass(disabledGroup[order],"disabled");liProhibitedGroup[order].removeEventListener("click",li1);}
     //a
     //order 
    disabledGroup[order].onclick=function () {
        if (order < disabledGroup.length) {orderPP;}
        // for (var i = 0; i < liProhibitedGroup.length; iPP) {liProhibitedGroup[i].removeEventListener("click",li1);}
        removeClass(disabledGroup[order], "disabled"); //disabled
        liProhibitedGroup[order].removeEventListener("click", li1); //
        console.log(order); //
};
}
addLoadListener(liRemind);
function liRemind() {
    var liGroup=document.getElementsByClassName("liProhibited");
    for(var i=0;i<liGroup.length;iPP){
        liGroup[i].addEventListener("click",li)}
}
function li() {
    alert("liProhibitedli")
}
function removeLiRemind() {
    var liGroup=document.getElementsByClassName("liProhibited");
    for(var i=0;i<liGroup.length;iPP){
        liGroup[i].removeEventListener("click",li)}
}
function li1() {
    alert("liProhibited class li2");
}
</script>

process:
1: click for the first time: normal

clipboard.png

::disbledGroup[order]

clipboard.png

question:
when disbledGroup [order] runs for the first time, that is, when order equals 0, it runs normally. After running, the accumulation method of order makes order=1, but cannot return order=1 to re-assign the second tag to click event;
however, the click method of the first a tag does not disappear. You can also continue to click the first a tab and continue to execute the disbledGroup [order] click event.

Mar.28,2021

I wrote a simple example with jQuery . Check to see if my idea is correct:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        ul li{
            line-height: 2em;
            background-color: orange;
            margin: 0.5em;
        }
    </style>
</head>
<body>
    <ul id="ul">
        <li data-index="1">1</li>
        <li data-index="2">2</li>
        <li data-index="3">3</li>
    </ul>
    <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
    <script>
        $(function() {
            var _index = 1;
            $("-sharpul").on("click", function(ev){
                var index = $(ev.target).data("index");
                var len = ev.currentTarget.children.length;
                if(_index === index){
                    _indexPP;
                    console.log("")
                } else {
                    console.log("");
                    return false;
                }
                if(index === len) {
                    _index = 1;
                    console.log("");
                } 

                return;
            });
        });
    </script>
</body>
</html>

add a switch. When you click on the first step, turn on the switch of the second step. Do not turn on, cannot click, and so on

Menu