Difference between revisions of "Template:HKJS S/Javascript/Notebook"

Line 34: Line 34:
  
 
function scrollFunction() {
 
function scrollFunction() {
     if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
+
     if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
 
         document.getElementById("top_btn").style.display = "block";
 
         document.getElementById("top_btn").style.display = "block";
 
     } else {
 
     } else {

Revision as of 08:43, 28 September 2018

function expandall(){ var value = ["229"]; var i; for (i = 0; i < value.length; i++){ var a = value[i]; document.getElementById(a).style.display = "block"; var b = a + "_btn"; document.getElementById(b).innerHTML = "[Hide]"; } } function collapseall(){ var value = ["229"]; var i; for (i = 0; i < value.length; i++){ var a = value[i]; document.getElementById(a).style.display = "none"; var b = a + "_btn"; document.getElementById(b).innerHTML = "[Show]"; } } function expand(value){ var a = value + "_btn"; var btn = document.getElementById(a) if(btn.innerHTML == "[Show]"){ document.getElementById(value).style.display = "block"; document.getElementById(a).innerHTML = "[Hide]"; }else{ document.getElementById(value).style.display = "none"; document.getElementById(a).innerHTML = "[Show]"; } } window.onscroll = function() {scrollFunction()}; window.onload = function() {scrollFunction()};

function scrollFunction() {

   if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
       document.getElementById("top_btn").style.display = "block";
   } else {
       document.getElementById("top_btn").style.display = "none";
   }

}