v1
11/19/2018 by juanlu 11/19/201800
disable setup HTML
Setup HTML
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<select>
	<option value="A" selected>Option A</option>
	<option value="B">Option B</option>
	<option value="C">Option C</option>
	<option value="D">Option D</option>         
</select>
Setup JS - click to add setup JavaScript
delete caserun single casemove downdrag and drop case


ready



$("select").each(function () {
	$(this).val($(this).find('option[selected]').val());
});
delete caserun single casemove upmove downdrag and drop case


ready



let selects = document.getElementsByTagName('select');

for (let i = 0; i < selects.length; ++i) {
    let currentSelect = selects[i];
    let selectedOption = currentSelect.querySelector('option[selected]');
    if (selectedOption) currentSelect.value = selectedOption.value;
}
delete caserun single casemove updrag and drop case


ready



$('select').each(function () {
    var select = $(this);
    var selectedValue = select.find('option[selected]').val();

    if (selectedValue) {
      select.val(selectedValue);
    } else {
      select.prop('selectedIndex', 0);
    }
});
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN