I have a dropdown with several html favorites. I want to programmatically (via jquery) select all the values ββin a dropdown list. How can i do this?
If the element has an id test
$('#test option').attr('selected', 'selected');
JSFiddle example
Or, as Ryan said, you can use .prop
.prop
$('#test option').prop('selected', true); // or pass false to deselect them
Just $("#dropdown").val([0, 1, 2, 3]) , where 0 , 1 , 2 , 3 values ββyou want to select.
$("#dropdown").val([0, 1, 2, 3])
0
1
2
3