I made a post on how with a choice, select all items. I got an answer, which it solved. well, it solved only in Chrome, but IE does not work. As the question changed the "direction", then I decided to do another post. It includes other versions of jquery and even then it did not work. This is the code for my select (html).
<tr>
<td width="10%" class="label_right">Autorização Prévia: </td>
<td class="label_left">
<select id="ddl_autorizacaoprevia" multiple="multiple" >
<option value="0">TODAS AS AUTORIZAÇÕES</option>
<option value="T">TÉCNICA / ADMINISTRATIVA</option>
<option value="A">SISTÊMICA</option>
<option value="N">NÃO PRECISA</option>
</select>
</td>
</tr>
This is the jquery that selects all items in a single click:
$('#ddl_autorizacaoprevia option').click(function () {
var that = $(this);
if (that.val() == 0) {
$('#ddl_autorizacaoprevia option').each(function () {
$(this).attr('selected', 'selected');
});
} else {
$('#ddl_autorizacaoprevia option').each(function () {
$(that).removeAttr('selected');
});
$(that).attr('selected', 'selected');
}
});
So this code works fine in Chrome, but it does not work in IE. What can it be? Only works with Ctrl + Click, then I can select all, but only when clicking the first index (index = 0), there does not select all the items, but in Chrome works and the company-approved browser is IE and not chrome logo I have to make it work in IE.