jQuery 无法在层次结构中的指定点插入节点”代码:“3

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1119211/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 10:42:46  来源:igfitidea点击:

Node cannot be inserted at the specified point in the hierarchy" code: "3

jquerygrid-layout

提问by mourique

Hey, it's me again with a question about jquery and that gridlayoutI made a php template with switch and the code i am inserting is this

嘿,我又是一个关于 jquery 和gridlayout的问题,我用 switch 制作了一个 php 模板,我插入的代码是这个

<div id="wrapper">

<div id="grid">
<div class="box"><img src="img/an_005_BUR_thebeat.jpg" width="310px" height="438px" />3 index</div>
<div class="box"><img src="img/an_014_GUE_homme_a.jpg" width="310px" height="404px" />4 Culture</div>
<div class="box"><img src="img/an_044_BVL_springmotiv.jpg" width="310px" height="310px" />5 Pharma</div>
<div class="box"><img src="img/an_039_AN_diskette.jpg" width="310px" height="465px" />6 Pharma IT</div>
<div class="box"><img width="310px" height="100px" />7 Culture</div>
<div class="box"><img width="310px" height="120px" />8 Cosmetics</div>
<div class="box"><img width="310px" height="400px" />9 IT</div>
<div class="box"><img width="310px" height="400px" />10 Culture</div>
<div class="box"><img width="310px" height="400px" />11 IT</div>
<div class="box"><img width="310px" height="400px" />12 Culture</div>
</div>

</div>
    <script type="text/javascript">

    $(document).ready(function(){

        $('#grid').gridLayout('.box', {col_width: 340, min_cols: 2});
        // options - (values above are the defaults)
        // col_width: the width of each grid block
        // min_cols: the minimum number of cols on the page (reducing browser width below this will not decrease number of columns). Set to your largest block (3 = block spans 3 columns)

        // gridLayout.placeAtEnd() - for placing a block at bottom right of grid
        var final_block = $('');
        $('#grid').gridLayout.placeAtEnd( final_block );

        // gridchange event fires when window resize forces a grid refresh
        $('#grid').bind( "gridchange", function(e){
            console.log('gridchange event fired');
            // reposition the final block
            $('#grid').gridLayout.placeAtEnd( final_block );
        });

        // this forces a redraw of grid
        $('body').gridLayout.refresh();

        // returns heights of each column
        console.log( 'gridLayout.info():', $('#grid').gridLayout.info() );
    });

</script>

The jquery script and the plugin are loaded in the header. When i try to run this. Firebug tells me:

jquery 脚本和插件加载在标题中。当我尝试运行它时。萤火虫告诉我:

"Node cannot be inserted at the specified point in the hierarchy" code: "3"

“无法在层次结构中的指定点插入节点”代码:“3”

Do anybody know how to fix this?

有人知道如何解决这个问题吗?

Here is an example i loaded up: http://18735.webhosting7.1blu.de/neu/index.php?item=lifestyle

这是我加载的一个例子:http: //18735.webhosting7.1blu.de/neu/index.php?item=lifestyle

回答by redsquare

I am pretty sure your error is with the following. What is $('') !

我很确定您的错误与以下内容有关。什么是 $('') !

var final_block = $('');
$('#grid').gridLayout.placeAtEnd( final_block ); 

It works if I say

如果我说它有效

var final_block = $('<div />');
$('#grid').gridLayout.placeAtEnd( final_block );

回答by CodeReaper

The error message is displayed (in firebug) if you have incorrect html in a $() constructor, as well as when you try to append a node to itself, e.g.:

如果 $() 构造函数中的 html 不正确,以及尝试将节点附加到自身时,则会显示错误消息(在 firebug 中),例如:

$div = $('<div />');
$div.append($div);