IE8的JQuery问题:预期的标识符

时间:2012-06-14 20:00:29

标签: jquery internet-explorer cross-browser

我尝试了一些我在这里搜索的修复,但它们似乎没有工作......

我得到一个预期的标识符,字符串或数字字符36,所以开头括号。我尝试用双引号替换所有单引号无变化......

if (($('#attachment_asset').length) && ($('p.please-wait').length == 0)) {
    $('.buttons').append($('<p/>', {
        class: 'please-wait', 
        text: 'Please wait, uploading your file...'
    }));
}

似乎无处不在,但IE ...

3 个答案:

答案 0 :(得分:4)

Word class seems to be reserved in IE。尝试用引号括起来:

$('.buttons').append($('<p/>', {
    "class": 'please-wait',
    text: 'Please wait, uploading your file...'
}));

答案 1 :(得分:0)

没错。

问题发生在文件中的其他内容的组合。发布整个文件。这在ie9中工作正常。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> New Document </title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>

  <script language="javascript">
if (($('#attachment_asset').length) && ($('p.please-wait').length == 0)) {
    $('.buttons').append($('<p/>', {class: 'please-wait', text: 'Please wait, uploading your file...'}));
}
  </script>
 </head>

 <body>

 </body>
</html>

答案 2 :(得分:0)

试试这个

$('.buttons').append($("<p>").addClass("please-wait").append("Please wait, uploading your file..."));