Search code examples
jqueryhtmlhtml-tableinternet-explorer-8internet-explorer-7

IE7 & 8 jQuery Problems


I have a jQuery script, that will not work in IE7 or IE8. Interestingly, there are a few other jQuery scripts active on the page, and these all function, but the one below simply does not work.

I have created this jsFiddle to demonstrate the functionality. This works in IE9+, Chrome and Firefox.

This code updates textbox values based on certain criteria:

$(function () {
    $(".TAB1text1").change(function () {
        var $tr = $(this).parent().parent();
        var type = $tr.find("td:eq(1)").text();
        var scale = $tr.find("td:eq(6) input").val();
        if (type == " CERTAIN_TEXT_TOTAL " && (scale == 3 || scale == 3.0)) {
            $(".TAB1text1").not(this).val($(this).val());
        }
    });
});

Can anyone spot any functions / errors that would cause these scripts to stop functioning in IE7 and IE8?


Solution

  • I managed to work a solution to this problem.

    First up, the .trim() did not work (so I edited my source code to remove the spaces:

    $(function () {
        $(".TAB1text1").change(function () {
            var $tr = $(this).parent().parent();
            var type = $tr.find("td:eq(1)").text();
            var scale = $tr.find("td:eq(6) input").val();
            if (type == " CERTAIN_TEXT_TOTAL " && (scale == 3 || scale == 3.0)) {
                $(".TAB1text1").not(this).val($(this).val());
            }
        });
    });
    

    Next, I had to tweak the <meta> tag within the HTML <head> tag to include:

    <meta content="IE=EmulateIE7">
    

    I'm going to leave this here for future reference - I hope it helps.