Hi, I have on my page
<select name="select-choice" id="select-choice" > element with some options values, for example
<option id="cityA" value="cityA" class="remove">Paris</option>
I have two questions
- at first
I would like sort this elements alphanumeric. I am using this code
try{
$("#select-choice('option[class*='remove']'").remove();
}catch(e){
alert('Error when sorting');
}
After sorting I can see alert with error message, but elements are removed! IntellijIdea show error on this line - Selector matches unknown element remove.
- second
when my app starts, it loads values form local store and sets elements on page. All works fine except elements <select name="nameOfSelect" id="idOfSelect" >....
my code
if(condition) {
$('#select-choice option')[2].selected = true;
...next code
It works, I can see "checked" on this position, but I would like show this value (row) as a first in my select element.
Thanks you for your help me.
Regards