I am new to java script i am doing one event that is when i clicking the plus button the css style was printed but value not increase. and same as clicking menus button the last child is not removed...
i want to print the css style and incremented value and same decrease value and delete the last child........
below is my html
var counter = 0;
var numBoxes = 10;
function myFun(showDiv) {
var ele = document.getElementById(showDiv + counter);
if(counter>numBoxes) {
document.getElementById("incBtn").addEventListener("click", function(){
document.getElementById("demo").innerHTML = "Limit Is Over";
});
}
else {
ele.style.display = "block";
}
if(counter>0) {
ele.style.display = "block";
}
else {
document.getElementById("decBtn").addEventListener("click", function(){
document.getElementById("demo").innerHTML = "Limit Is Over";
});
}
}
<div class="divInfo">
<span id="box1" style="border: 1px solid black; background: #CCCCCC; display: none;padding: 2px;height:90px;width:10px;float:left;"></span>
<span id="box2" style="border: 1px solid black; background: #CCCCCC; display: none;padding: 2px;height:90px;width:10px;float:left;margin-left:10px;"></span>
<span id="box3" style="border: 1px solid black; background: #CCCCCC; display: none;padding: 2px;height:90px;width:10px;float:left;margin-left:10px;"></span>
<span id="box4" style="border: 1px solid black; background: #CCCCCC; display: none;padding: 2px;height:90px;width:10px;float:left;margin-left:10px;"></span>
<span id="box5" style="border: 1px solid black; background: #CCCCCC; display: none;padding: 2px;height:90px;width:10px;float:left;margin-left:10px;"></span>
<span id="box6" style="border: 1px solid black; background: #CCCCCC; display: none;padding: 2px;height:90px;width:10px;float:left;margin-left:10px;"></span>
<span id="box7" style="border: 1px solid black; background: #CCCCCC; display: none;padding: 2px;height:90px;width:10px;float:left;margin-left:10px;"></span>
<span id="box8" style="border: 1px solid black; background: #CCCCCC; display: none;padding: 2px;height:90px;width:10px;float:left;margin-left:10px;"></span>
<span id="box9" style="border: 1px solid black; background: #CCCCCC; display: none;padding: 2px;height:90px;width:10px;float:left;margin-left:10px;"></span>
<span id="box10"style="border: 1px solid black; background: #CCCCCC; display: none;padding: 2px;height:90px;width:10px;float:left;margin-left:10px;"></span>
</div>
<div class="divInfo2">
<input type="text" id="value" value="0">
</div>
<div class="IncDrc">
<input id="incBtn" type="button" value="+" onclick="counter++; myFun('box');">
<input id="decBtn" type="button" value="-" onclick="counter--; myFun('box');">
</div>
<div>
<p id="demo"></p>
</div>