I created a function with various if statements,that will be executed if a parameter is true. But passing false as a parameter doesn't seem to work. What am I doing wrong?
function easySlider(titleP, subTitleP, overlayP) {
var title = titleP;
var subTitle = subTitleP;
var overlay = overlayP;
if (title === true) {
$(".sliderTitle").css("display", "block");
} else {
$(".sliderTitle").css("display", "none");
}
if (subTitle === true) {
$(".sliderSubTitle").css("display", "block");
} else {
$(".sliderSubTitle").css("display", "none");
}
if (overlay === true) {
$(".sliderOverlay").css("display", "block");
} else {
$(".sliderOverlay").css("display", "none");
}
}
easySlider(true, false, true);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h2 class="sliderTitle">Hello sliderTitle</h2>
<h3 class="sliderSubTitle">Hello sliderSubtTitle</h3>
<div class="sliderOverlay">Hello sliderOverlay</div>
.hideand.show...toggle(): jsfiddle.net/ag0myjes/1