change image upon selection, searching list for the src value jQuery
- by Charles Marsh
Hello all,
Can anyone see anything that is wrong with this code it just isn't working...
Should be clear what I am trying to do
jQuery(document).ready(function($) {
$('#product-variants-option-0').change(function() {
// What is the sku of the current variant selection.
var select_value = $(this).find(':selected').val();
if (select_value == "Kelly Green") {
var keyword = "kly";
};
var new_src = $('#preload img[src*="kly"]');
$('div.image').attr('src', new_src);
});
});
The selection:
<select class="single-option-selector-0" id="product-variants-option-0">
<option value="Kelly Green">Kelly Green</option>
<option value="Navy">Navy</option>
<option value="Olive">Olive</option>
<option value="Cocoa">Cocoa</option>
</select>
I'm trying to search an unordered list:
<ul id="preload" style="display:none;">
<li>0z-kelly-green-medium.jpg</li>
<li>0z-olive-medium.jpg</li>
</ul>