I am trying to make input enable when some option is selected from the drop-down
I wrote code for solving this problem, but it doesn't work. Here is my code
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<body>
<select class="form-control" id="dropDown">
<option id="n" value="0"> Тип N </option>
<option id="p" value="1"> Тип P </option>
<option id="c" value="2"> Тип C </option>
<option id="v" value="3"> Тип V </option>
<option id="t" value="4"> Тип T </option>
<option id="s" value="5"> Тип S </option>
</select>
<div>
<label class="control-label">
<span th:text="#{size}"></span>
</label>
<input id="size" type="text" class="form-control" />
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script th:inline="javascript">
$('#dropdown').change(function() {
if( $(this).val() === 1) {
$('#size').props( 'disabled', false );
} else {
$('#size').props( 'disabled', true );
}
});
</script>
</body>
</html>
So I'm expecting that when I select the option "Тип P" input (id="size") should be enabled, if other options selected it should stay disabled
.props(). And you have$('#dropdown')but the ID isdropDown(note the case)