仅在使用jquery的IE浏览器中出现脚本错误?

时间:2013-06-25 12:29:33

标签: javascript jquery html css html5

我喜欢使用HTML / javascript / jquery。但我单独在IE中遇到错误。我正在使用IE7和XP。

enter image description here

下面是代码:

$(function(){
    $("select").multiselect();
    var i =1;
    $("select").change(function () {
        var str = $(this).val();
        $('.lbCriteriaContainer').html('');
        $.each(str, function(index, value) {
            var liTag = $('<li class="lbAlt"></li>');
            var removeIcon= $('<img src="images/cross.jpg" style="cursor: pointer;width: 15px;padding-top: 3px;">');
            var textElement=$('<span>'+value+'</span>');
            liTag.append(removeIcon);
            liTag.append(textElement);
            $('.lbCriteriaContainer').append(liTag);

            removeIcon.bind('click',function(){
                liTag.remove();
                $('select [value='+value+']').removeAttr('selected');
                $('select').multiselect('refresh');
            });
        });

    }).change();


<script type="text/javascript" src="js/jquery-1.6.js" ></script>

<link rel="stylesheet" type="text/css" href="css/jquery.multiselect.css" />
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/ui-lightness/jquery-ui.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<script src="js/jquery.multiselect.js" type="text/javascript"></script>

谢谢!

1 个答案:

答案 0 :(得分:2)

你错过了$(function(){声明的右括号和括号:

并且此部分应该在加载所有包含的脚本之后;) - jogesh_pi

<link rel="stylesheet" type="text/css" href="css/jquery.multiselect.css" />
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/ui-lightness/jquery-ui.css" />
<script type="text/javascript"  src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<script src="js/jquery.multiselect.js" type="text/javascript"></script>

$(function(){
    $("select").multiselect();
    var i =1;
    $("select").change(function () {
        var str = $(this).val();
        $('.lbCriteriaContainer').html('');
        $.each(str, function(index, value) {
            var liTag = $('<li class="lbAlt"></li>');
            var removeIcon= $('<img src="images/cross.jpg" style="cursor: pointer;width: 15px;padding-top: 3px;">');
            var textElement=$('<span>'+value+'</span>');
            liTag.append(removeIcon);
            liTag.append(textElement);
            $('.lbCriteriaContainer').append(liTag);

            removeIcon.bind('click',function(){
                liTag.remove();
                $('select [value='+value+']').removeAttr('selected');
                $('select').multiselect('refresh');
            });
        });

    }).change();
});