Follow the code:
<select class="form-control" name="dd_medidaAplicada" id="dd_medidaAplicada">
<option value="0"></option>
<option value="cancelada">Advertência Cancelada</option>
<option value="escrita">Advertência Escrita</option>
<option value="verbal">Advertência Verbal</option>
<option value="dispensa">Dispensa por Justa Causa</option>
<option value="suspensao">Suspensão</option>
I want to run a script every time you change the selected item:
$("input[name=dd_medidaAplicada]").on('change', function() { alert( this.value );})
However, through the name attribute I can not execute. If I use the ID attribute, it works! Here's an example:
$("#dd_medidaAplicada").on('change', function() { alert( this.value );})
In this way, Alert runs smoothly. And yes, I could use the ID attribute, but many times this same problem happens in my codes and I'm tired of creating an ID just to execute a code. I want to understand why not run.