IE和FF之间的下一个区别? [英] nextSibling difference between IE and FF?

查看:129
本文介绍了IE和FF之间的下一个区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在raphaeljs中编写了一个用于分层的javascript代码,它在FF上完美运行。
但它不适用于IE。问题是IE返回 null 对于任何对象的 nextSibling

I just wrote a javascript code for layering in raphaeljs it works perfectly on FF. But it doesn't on IE. The problem is IE returns null for nextSibling for any object.

如何正确使用它,或者IE中是否有 nextElementSibling 调用?

How does one use it correctly, or is there a nextElementSibling call in IE?

这是代码片段我用来改变对象的顺序:

Here is the code fragment I used to change the order of objects:

n = items[selected_item_id].nextSibling.id;
if (n != '') {
  items[selected_item_id].insertAfter(items[n]);
}







<div id="consarea">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%">
<desc>Created with Raphaël</desc>
<defs/>
<rect x="188" y="100" width="200" height="200" r="10" rx="10" ry="10" fill="#ee8515" stroke="none" style="opacity: 1;" opacity="1"/>
<rect x="253" y="158" width="50" height="50" r="0" rx="0" ry="0" fill="#0080ff" stroke="none" style="opacity: 1;" opacity="1" id="0"/>
<rect x="230" y="140" width="50" height="50" r="0" rx="0" ry="0" fill="#c03022" stroke="none" style="opacity: 1;" opacity="1" id="1"/></svg>

此处在上方。 html的一块工作

here it is above. the piece of the html im working on

推荐答案

尝试使用以下功能。它是下一个兄弟的跨浏览器代码段。

Try to use the following function. It is a cross browser code snippet for next sibling.

    function getNextElementSibling(CurrentElement) {
    if (CurrentElement.nextElementSibling) {
        return CurrentElement.nextElementSibling
    } else {
        do {
            CurrentElement = CurrentElement.nextSibling;
        } while (CurrentElement && CurrentElement.nodeType !== 1);
        return CurrentElement;
    }
}

这篇关于IE和FF之间的下一个区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆