javascript - After angular filter on options if only one option is left, select it -
I have two selected boxes, one takes the box which the other has chosen and its as a filter for myself Sometimes the filter leaves only one option. I'm looking for an option to choose that option only if it's the only one in the list.
If this is very unclear then I can put an example.
Thanks in advance.
This is not an angular related question. But here's the answer using jQuery:
var numitems = $ ('# myselect'). Children ('Options') Length; If (numitems == 1) {$ ("# myselect option: first"). Ether ('selected', 'selected'); // just select the first}
If you know the value $ ('[name = myselect]'), then you can also choose from the price. Val (3); // Choose from a value == 3
You can also select by text.
Comments
Post a Comment