题
嘿,这又是我一个关于jQuery的问题和网格布局我犯了一个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>
在jQuery脚本和插件被装载在首部。当我尝试运行此。萤火虫告诉我:
“3”码“节点不能在分层结构中的指定点插入的”
难道有人知道如何解决这一问题?
下面为i装起来的例子: HTTP:// 18735。 webhosting7.1blu.de/neu/index.php?item=lifestyle
解决方案
我敢肯定你的错误是与以下。什么是$( '')!
var final_block = $('');
$('#grid').gridLayout.placeAtEnd( final_block );
它的工作原理,如果我说
var final_block = $('<div />');
$('#grid').gridLayout.placeAtEnd( final_block );
其他提示
显示(在Firebug)的错误信息,如果你有不正确的HTML在$()构造函数,以及当您尝试一个节点追加到自身,e.g:
$div = $('<div />');
$div.append($div);
不隶属于 StackOverflow