For example, i have <div id="titlebar"></div>
inside html, and also i have <div class="name">Content-text</div>
inside same html. Now i want pass Content-text of div class name (<div class="name">Content-text</div>
) to another my id <div id="titlebar"></div>
through css
or js
. i tried several ways, but no effect
And when i scroll up the html the id titlebar
will show the text of class name
My html:
<html>
<body>
<div id="titlebar"></div>
<div class="name">Content-text</div>
</body>
</html>
Css:
#titlebar{
text-align:center;
width: 101%;
position: fixed;
top:0px;
margin-left:-10px;
padding-right:1px;
font-family: Times New Roman;
font-size: 16pt;
font-weight: normal;
color: white;
display:none;
border: none;
}
Javascript:
window.onscroll = function() {scrollFunction()};
function scrollFunction() {
if (document.body.scrollTop > 150 || document.documentElement.scrollTop > 150) {
document.getElementById("titlebar").style.display = "block";
} else {
document.getElementById("titlebar").style.display = "none";
}
}