Within my code, I have several select elements structured as follows:
<li>
<select>
<option>choose something</option>
<option value="1">something</option>
<option value="2">anything</option>
</select>
</li>
<li>
<select>
<option>choose something</option>
<option value="1">something</option>
</select>
</li>
<li>
<select>
<option>choose something</option>
<option value="1">something</option>
</select>
</li>
My goal is to adjust the opacity of each select element to 0.5 if it has a selected option after the page has loaded. Initially, I attempted to achieve this using jQuery:
$('select').each(function(select) {
$('select option').each(function() {
if($(this).is(':selected')) {
select.css({ opacity: 0.5 });
}
});
});
However, this approach did not yield the desired results.