Hello, I'm trying to use the Jquery checkbox,
And the second question is whether there is a better (simpler) way to get the same result.
I thought that I had succeeded, through a previous question but an error appeared.
Thanks in advance.
Hello, I'm trying to use the Jquery checkbox,
And the second question is whether there is a better (simpler) way to get the same result.
I thought that I had succeeded, through a previous question but an error appeared.
Thanks in advance.
Using jQuery just do
select.prop('selectedIndex', 0);
like this: link . So it tells select to use as a choice the option
with index 0
, that is the first.
You can also use select.val('');
which has the same effect. In some browsers this solution does not choose the first choice but rather leaves no choice, blank.
With native JavaScript it would be el.selectedIndex = 0;
The commented line in your example:
// $('select').prop('selectedIndex', 0);
was already very close to the solution. The problem is that $('select')
returns all page selects, and then all of them were restarted when any checkbox was checked.
You can restrict only to the select within the cell you are hiding. Only use id
of her cell:
$('#e' + index + ' select').prop('selectedIndex', 0)
A very easy way to do this, for example, by the value
of the option you want to select ... in the example I select the value
empty:
$('#id option[value=""]').attr('selected', 'selected');