Stuck on conditionally enable or disable input with JQuery
Posted
by dmr
on Stack Overflow
See other posts from Stack Overflow
or by dmr
Published on 2010-06-09T13:50:49Z
Indexed on
2010/06/09
13:52 UTC
Read the original article
Hit count: 255
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>
© Stack Overflow or respective owner