Why does the jQuery on this page work for Internet Explorer 8, but nothing else?

Posted by Ben McCormack on Stack Overflow See other posts from Stack Overflow or by Ben McCormack
Published on 2010-06-18T02:37:55Z Indexed on 2010/06/18 2:43 UTC
Read the original article Hit count: 333

I made a web page that uses jQuery: http://benmccormack.com/demo/MichaelMassPsalm/Psalm16Mode5.html

When you change the selection in the combo box from Higher Key to Lower Key, all of the music images are supposed to change their source to be images that represent the lower key signature. This works great in IE8, but it won't work in Safari, Firefox, or Chrome.

Why not?


Here's the jQuery code that I'm using:

$(document).ready(function () {
    $("#musicKey").change(function (event) {
        if ($("#musicKey").val() * 1) {
            $("img[src*='Low'").each(function (index) {
                $(this).attr("src", $(this).attr("src").replace("Low", "High"));
            });
        }
        else {
            $("img[src*='High'").each(function (index) {
                $(this).attr("src", $(this).attr("src").replace("High", "Low"));
            });
        }
    });
});

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery