change image upon selection, searching list for the src value jQuery

Posted by Charles Marsh on Stack Overflow See other posts from Stack Overflow or by Charles Marsh
Published on 2010-12-21T23:10:16Z Indexed on 2010/12/21 23:54 UTC
Read the original article Hit count: 437

Filed under:
|
|

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>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about select