document.addEventListener("DOMContentLoaded", () => {
    var head = document.querySelector("head");
    var newcss;
    let cssbtn1 = document.getElementById("css1");
    let cssbtn2 = document.getElementById("css2");
    let cssbtn3 = document.getElementById("css3");
    
    //function bg1(){
    cssbtn1.addEventListener("click", (e) => {  
	if (newcss) return;
	newcss = document.createElement("link");
	newcss.rel = "stylesheet";
	newcss.href = "new1.css";
	head.appendChild(newcss);	// link要素を追加
    });

    cssbtn2.addEventListener("click", (e) => {  
        if (newcss) return;
        newcss = document.createElement("link");
        newcss.rel = "stylesheet";
        newcss.href = "new2.css";
        head.appendChild(newcss);	// link要素を追加
        });

    //function bg3(){
    cssbtn3.addEventListener("click", (e) => {  
            if (newcss) return;
            newcss = document.createElement("link");
            newcss.rel = "stylesheet";
            // ※newcss.title = "あとから版";	// title属性入れると代替CSSに
            newcss.href = "new3.css";
            head.appendChild(newcss);	// link要素を追加
            });
            /*if(bg2 && bg1){
                    newcss.remove();
                    newcss = null;
            }*/
        //}
        let unlbtn = document.getElementById("unl");
        unlbtn.addEventListener("click", (e) => {
            if (newcss) {
                newcss.remove();
                newcss = null;
            }
        }); 
});
