I have a page with a select and a textbox. I want keep disabled the textbox if the option selected is different than "Altro". How can I do? I tried something by my textbox is always disabled.
HTML:
<p>Partenza: <select id="selPartenza">
<option class="opt" value="0">Altro</option>
<option class="opt" value="1">Opt1</option>
<option class="opt" value="2">Opt2</option>
</select>
</p>
<textarea id="textP" placeholder="Aggiungi qui l'indirizzo di partenza se non lo trovi mell'elenco precedente."></textarea>
Javascript:
$("#selPartenza").each(function(i){
$(this).click(function () {
if(i==0) { //1st option
$("#textP").attr("disabled", "disabled");
} else {
$("#textP").removeAttr("disabled");
}
});
});
Obviously I'm not able to select the options in my script. How can I do? Thank you for your answers.