I thought this would be nice and simple; however, I cannot seem to get it to work. I am trying to get a DIV element to fade in and out depending on if a checkbox is selected, instead of just appearing and disappearing in an instant.
Here is my code:
HTML -
<div id="logPad" name="logPad" class="buttonZ logPad" onclick="remfunc2();"></div>
<div class="logSlider">
<input type="checkbox" name="logSlider" class="logSlider-checkbox"
id="logSlider" tabindex="0" onclick="sliderJS();" />
<label class="logSlider-label" for="logSlider">
<span class="logSlider-inner"></span>
<span class="logSlider-switch"></span>
</label>
</div>
CSS for the 'logPad'-
.logPad {
min-width: 225px;
display: none;
max-height: 200px;
min-height: 15px;
transition: 10s;
}
Now I'm not sure where the transition should be applied, I was thinking through JavaScript most likely, so I have tried a few things, but I am still learning JS and not that great at it.
This is my JS for hiding and showing the logPad div on 'checkbox' toggle, the toggle has been converted into a slider rather than a checkbox, this is done through CSS but I'm not sure this is relevant here as im sure the CSS for the slider is not where the transition for the logPad div will go.
function sliderJS() {
var checkBox = document.getElementById("logSlider");
if (checkBox.checked == true) {
document.getElementById('logPad').style.display = "block";
} else {
document.getElementById('logPad').style.display = "none";
}
}
Please can someone explain where this would be applied? the current transition in the class does not have an effect.