Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用id选择器的jQuery和ie8似乎不起作用(使用1.5.1)_Jquery_Internet Explorer 8_Selector - Fatal编程技术网

使用id选择器的jQuery和ie8似乎不起作用(使用1.5.1)

使用id选择器的jQuery和ie8似乎不起作用(使用1.5.1),jquery,internet-explorer-8,selector,Jquery,Internet Explorer 8,Selector,我正在创建一个鉴定旋转器,它解析一个充满鉴定的XML文件。每个推荐信都指定了一个“类别”,以便页面可以指定要使用的推荐信类别(例如“公司”或“高尔夫”,并显示相关参考。) 问题是,在IE8中(即使包含兼容元),特定ID中的html没有更改。我切换到类以确保Chrome正常工作(Firefox总是正常工作) 下面是使用类的示例: $("span.quote").html("&quot;" + $(this).find("quote").text() + "&quot;<br

我正在创建一个鉴定旋转器,它解析一个充满鉴定的XML文件。每个推荐信都指定了一个“类别”,以便页面可以指定要使用的推荐信类别(例如“公司”或“高尔夫”,并显示相关参考。)

问题是,在IE8中(即使包含兼容元),特定ID中的html没有更改。我切换到类以确保Chrome正常工作(Firefox总是正常工作) 下面是使用类的示例:

 $("span.quote").html("&quot;" + $(this).find("quote").text() + "&quot;<br />");
//print each testimonial name, title, and org if exists

  $("span.attrib").html("- " + $(this).find("name").text() + "");
  $("span.attrib").append(", " + $(this).find("title").text() + "");
  $("span.attrib").append(", " + $(this).find("organization").text() + "<br />");
$(“span.quote”).html(“+$(this.find)(“quote”).text()+”
); //打印每个推荐名称、标题和组织(如果存在) $($span.attrib”).html(“-”+$(this.find(“name”).text()+”); $(“span.attrib”).append(“,”+$(this.find(“title”).text()+”); $(“span.attrib”).append(“,”+$(this.find)(“organization”).text()+”
);
这些在Firefox和Chrome中工作。 下面使用ID选择器的代码仅在Firefox中有效,但这是我首选的方法

 $("#quote").html("&quot;" + $(this).find("quote").text() + "&quot;<br />");
//print each testimonial name, title, and org if exists

  $("#attrib").html("- " + $(this).find("name").text() + "");
  $("#attrib").append(", " + $(this).find("title").text() + "");
  $("#attrib").append(", " + $(this).find("organization").text() + "<br />");
$(“#quote”).html(“+$(this).find(“quote”).text()+”
); //打印每个推荐名称、标题和组织(如果存在) $(“#attrib”).html(“-”+$(this.find(“name”).text()+”); $(“#attrib”).append(“,”+$(this.find(“title”).text()+”); $(“#attrib”).append(“,”+$(this).find(“组织”).text()+”
);
我的HTML代码片段:

<span id="quote">
"This is the default quote."
</span>
<span id="attrib">
- Default name, default title, default organization
</span>

“这是默认报价。”
-默认名称、默认标题、默认组织
这段代码中有什么地方不正确,IE8不能正确地交换引号?当我将代码从选择器切换到警报(只是为了确保解析循环工作)时,一切正常

如有任何意见,我们将不胜感激。在这里不知所措。回到一个.NET或Flash项目,让它搁置几个小时

抢劫

添加了更多代码示例:

推荐书的内容

var filter_value = new String();

$(document).ready(readfilterXML("golf"));

function readfilterXML(passed_value)
{
    filter_value = passed_value;
  $.ajax({
    type: "GET",
    url: "testimonials.xml",
    dataType: "xml",
    success: parseXml
  });
}

function parseXml(xml)
{
    var holdclass = filter_value;
    // need to seek class within id "quote" like "#quote.class" to find out what it is
  //find every testimonial and load the array
  $(xml).find("testimonial").each(function()
  {
    var tempclass = $(this).attr("class");
//  $("#error").html(tempclass);
    if (tempclass == holdclass)  {
  $("span#quote").html("&quot;" + $(this).find("quote").text() + "&quot;<br />");
//print each testimonial name, title, and org if exists
  $("span#attrib").html("- " + $(this).find("name").text() + "");
  $("span#attrib").append(", " + $(this).find("title").text() + "");
  $("span#attrib").append(", " + $(this).find("organization").text() + "<br />");
}
});
}
var filter_value=new String();
$(document).ready(readfilterXML(“高尔夫”);
函数readfilterXML(传递的值)
{
过滤器_值=通过的_值;
$.ajax({
键入:“获取”,
url:“commissionals.xml”,
数据类型:“xml”,
成功:parseXml
});
}
函数解析xml(xml)
{
var holdclass=过滤器值;
//需要在id“quote”中查找类,如“#quote.class”,以了解它是什么
//找到每个推荐信并加载数组
$(xml).find(“推荐”).each(函数()
{
var tempclass=$(this.attr(“类”);
//$(“#error”).html(tempclass);
if(tempclass==holdclass){
$(“span#quote”).html(“+$(this).find(“quote”).text()+”
); //打印每个推荐名称、标题和组织(如果存在) $(“span#attrib”).html(“-”+$(this.find(“name”).text()+”); $(“span#attrib”).append(“,”+$(this.find(“title”).text()+”); $(“span#attrib”).append(“,”+$(this).find(“organization”).text()+”
); } }); }
您是否有多个具有相同id的
?如果要在html中使用多个引号,这些id看起来非常通用

如果您确实有多个相同的id,则每个浏览器将以不同的方式中断


另外,更多的代码会有帮助。

我不太理解
$(“#quote”).html(“+$(this).find(“quote”).text()+”
$(this.find(“quote”)中的
this
。text()
指的是
$(“#quote”)
,如果我没有弄错的话。因此,文本()将始终为空,因为
find(“quote”)
找不到任何内容。find语句中的“quote”(以及“name”、“title”和“organization”)来自一个存储推荐信的XML文件。下面是一组额外的代码:
$(this)
内的
$(“span#quote”)
指的是
$(“span#quote”)
,而不是
xml
中的每个
证明文件。只有一个具有此ID。始终只有一个quote和一个attrib ID。重点是使用jQuery在块中旋转引号。不幸的是,在IE中,html从未被替换(始终使用泛型,并且在替换中从不翻转)