如何剪切标题代码并将其附加到div标签中?

时间:2015-10-06 02:33:39

标签: jquery html

我想剪切我的标题代码并附加到public static boolean hasConsec(int arr[], int target) { int first = 0, last = 0; while (last < arr.length) { int sub[] = Arrays.copyOfRange(arr, first, last); int subSum = sumArr(sub); if (subSum == target) return true; else if (subSum < target) last++; else { if (++first < last) last = first; } } return false; } public static int sumArr(int arr[]) { int sum = 0; for (int i = 0; i < arr.length; i++) sum += arr[i]; return sum; } 。 标题太大,所以我无法将其粘贴到jQuery中并附加。

我想知道还有另外一种方法吗?我可以剪切我的代码并附加到div中吗?

我希望当我向下滚动100px时,我的标题会显示在postTopNotification div

这是我的一些标题代码:

postTopNotification div

这是<header> <div class="topMenuWrap"> <div class="logoWrap"> <a href="<?php echo site_url();?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/logo.jpg"></a> </div> <ul class="topMenu"> </ul> <div class="tip"> <a href="#"> <p>Got A Tip ?</p> <span>Let Us Know</span> </a> </div><!--- tip end--> <form id="headerSearch"> <div class="headSearchWrap"> </div> </form> </div> </header>

postTopNotification div

2 个答案:

答案 0 :(得分:0)

如果你正在使用php,为什么不在两个地方都做一个包含,如下所示:

<?php include 'header.html';?>

这将为您提供一个加载html的地方,这样您就不必在这两个地方进行更改,并且一旦加载就不需要做任何额外的工作。

答案 1 :(得分:0)

试试这个 $("header").appendTo(".postTopNotification");