2017-01-25 65 views
0

我需要顯示頁腳中的內容。但我想在標題中顯示它。是否可以使用jqueryjavascript在標題中顯示?如何使用javascript在頁眉中顯示頁眉內容?

+1

或許爲我們提供了一些代碼? – malutki5200

+0

可以分享屏幕截圖嗎? – Sunil

+0

https://jsfiddle.net/vinayakmali123/dLykpjxr/請檢查上面的例子我想要顯示的內容是在底部actully我想顯示的內容在標題中使用jquery –

回答

0

我不知道你想實現什麼,也許更多的信息會有用。但是你可以用下面的代碼來描述你所描述的內容。

<html> 
<head> 
    <meta charset="UTF-8"> 
    <script type="text/javascript"> 
    function changeHeader() 
    { 
    document.getElementById("header").innerHTML = document.getElementById("footer").innerHTML; 
    } 
    </script> 
</head> 
<body onload="changeHeader()"> 
    <div id="header" onclick="test()"></div> 
    <div id="footer"> 
    <p>test1</p> 
    <p>test2</p> 
    </div> 
</body> 
</html> 

如果你不希望顯示在頁腳中的數據了,你可以添加以下行:

document.getElementById("footer").innerHTML = ""; 
0

如果你只是想顯示在頁眉頁腳的內容,那麼在JavaScript你可以寫 -

HTML -

<html> 
<body> 
<header id="header"></header> 

<footer id="footer">Footer Content</footer> 
</body> 
</html> 

腳本 -

document.getElementById('header').innerHTML= document.getElementById('footer').innerHTML 

而且與其他一些內容,使頁腳填充 -

document.getElementById('footer').innerHTML = 'Some other Content' 
0

jQuery的方式:

$(document).ready(function() { 
 
\t $('#header').html($('#footer').html()); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<h3>Header:</h3> 
 
<div id="header"> 
 
</div> 
 
<h3>Footer:</h3> 
 
<div id="footer"> 
 
Some <i>HTML</i> 
 
</div>

UPDATE

這裏是JS,你想要做什麼:

$(document).ready(function() { 
    $('header').html($('footer').html()); 
}); 
0

here這是你在找什麼,希望它爲你工作。

footer = $('#move_to_Header').html(); header = $('#thisisheader').html(); $('#thisisheader').html(footer); $('#move_to_Header').html(header);