您好,我正在使用 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>
谢谢!
最佳答案
您缺少 $(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();
});
关于javascript - 仅在使用 jquery 的 IE 浏览器中出现脚本错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17297381/