I have a input with type hidden and two divs.
How can I change the div to display based on value of input with type hidden?
i want to set display none to the div with class activeno if input does not value. and if input has value i want to set display none to div that called activeyes and show the div with classname activeno .
i wrote the below code for add and remove the class but it does not work .
here is my snippet :
$( document ).ready(function() {
tmpval = $('#inputi').val();
if(tmpval == '') {
$('.activeyes').addClass('activeyes2');
} else {
$('activeno').addClass('activeno2');
}
});
.mysite h1{ display:block;}
.activeyes{ display:none !important;}
.activeyes2{ display:block !important;}
.activeno{display:none !important;}
.activeno2{display:block !important;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<input type="hidden" value="[##cms.query.enable##]" id="inputi"/>
<div class="mysite">
<h1 class="activeyes"> Yes active </h1>
<h1 class="activeno"> No not active </h1>
</div>
<h1>tags/