Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery/Javascript not running in IE7

The following script below is not running in IE7 but works perfectly fine in IE 8 + 9 and ALL other browsers. Even putting in the alert("something"); does not work - I have another script that is working fine and that is running in IE 7 perfectly.

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

Am I missing a DOCTYPE? Here is the script below;

var formPageTitle = $("div.hsRadarform td h3").text(); 

$('.AspNet-DataList td a').each(function (index) {        
    var listElementText = $(this).text();
    var shade = "faint";

    if(formPageTitle.toLowerCase() == listElementText.toLowerCase()) {
        shade = "dark";
    }

    //adding the numbered circles here using jQuery
    $(this).css({ 
        'background-image': 'url(/assets/img/radarstep' + (index + 1) + shade + '.png)',
        'background-repeat': 'no-repeat',
        'height': '25px',
        'width': '25px',
    });
});
like image 828
mjcoder Avatar asked Dec 10 '22 04:12

mjcoder


1 Answers

IE is very picky with trailing commas :

$(this).css({ 'background-image': 'url(/assets/img/radarstep' + (index + 1) + shade + '.png)',
    'background-repeat': 'no-repeat',
    'height': '25px',
    'width': '25px',
});

Should be

$(this).css({ 'background-image': 'url(/assets/img/radarstep' + (index + 1) + shade + '.png)',
    'background-repeat': 'no-repeat',
    'height': '25px',
    'width': '25px' // comma removed
});
like image 131
Manse Avatar answered Jan 03 '23 06:01

Manse