0

嗨,我正在使用 HTML/javascript/jquery。但我在 IE 中遇到了错误。我使用的是 IE7 和 XP。

在此处输入图像描述

下面是代码:

$(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>

谢谢!

4

1 回答 1

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();
});
于 2013-06-25T12:32:26.583 回答