I am new beginner in javascript and I realy want to learn it, I am recently tryng to make HTML editor with Codemiror with all posible options and settings. I know that this wil be hard for new beginner but I have faith. So right now am trying to make changable splitpane for the HTML Editor. I have the splitpane "Jquery splitpane" and I want to have the option to change between Horizontal and vertical view. But to do that I wil need to change the "classes" and the "IDS" of the divs that are used for the splitpane. The vertical splitpane have some classes and IDS and the horizontal have others. I found out how to toggle multiple classes at same time with button, but now I have trouble with the "IDS". I have modifiet a script found here in the site, but I cant get it to work. If you guys can help me solve the problem I wil realy appreciate it. So here is the script for toggling the ids:
#red {
background: red;
}
#blue {
background: blue;
}
#green {
background: green;
}
#yellow {
background: yellow;
}
<button href="#" class="buttontoggle buttontoggle2">changehtmlstyle</button>
<div id="blue" class="toggleelement">This is a div</div>
<div id="green" class="toggleelement2">This is a div</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
var clickCount = 0;
$(".buttontoggle").on("click", function() {
clickCount++;
$("div.toggleelement").attr("id", clickCount % 2 === 0 ? "blue" : "red");
});
</script>
<script type="text/javascript">
var clickCount = 0;
$(".buttontoggle").on("click", function() {
clickCount++;
$("div.toggleelement2").attr("id", clickCount % 2 === 0 ? "blue" : "red");
});
</script>
I can toggle one of the ids if I delete one of them, but I need more than 4 ids to toggle at same time.