I am attempting to conditionally enable or disable HTML input based on the value of a variable. The “disable” part is working well, but the “enable” isn’t, and I can’t figure out why.
The code:
<--if variable is true...-->
<div id="disabledSearch" class="searchBox disabled">
<script type="text/javascript">
$('#disabledSearch :input').attr('disabled', true);
</script>
<--if variable is false-->
<div id="enabledSearch" class="searchBox">
<script type="text/javascript">
//This line isn't working:
$('#enabledSearch :input').removeAttr('disabled');
</script>
Thanks @pointy – I changed the order now it works
Edit: I can’t seem to find the comment by @pointy that gave me this idea. However, the solution was that I changed around the order of the elements and javascript on the page.