Jquery prependTo但在后面
我需要在h1前面加上Jquery prependTo但在后面,jquery,Jquery,我需要在h1前面加上#列,但是在#左#列之后,现在它就在前面了。代码如下: <script type="text/javascript"> $(init); function init() { $('h1').prependTo('#columns'); } </script> 美元(初始); 函数init(){ $('h1').prependTo('#columns'); } .appendTo(“#left_column”)
#列
,但是在#左#列
之后,现在它就在前面了。代码如下:
<script type="text/javascript">
$(init);
function init() {
$('h1').prependTo('#columns');
}
</script>
美元(初始);
函数init(){
$('h1').prependTo('#columns');
}
.appendTo(“#left_column”)
是一个明显的建议,但会在该列关闭之前追加(cheers Rory,在评论中)
如果希望它在列之后,请使用
.after('left_column')
这是不正确的-它会将h1
放在#left_column
元素内部,而不是放在它之后。像这样$('h1')。附加到('left_column')。在('left#u column')之后?好的,它正在工作,下面是结果-$('h1')。insertAfter('left#u column');