javascript - Why color of navigation not changing -


hi writing code change navigation link colour based on url address not doesn't run please me. want change color of navigation link @ particular url address js code

function big(x){  x.style.fontsize = "17px"; x.style.color="#03c1cb"; } function small(x){ var y=location.hash; if(x.href== y){ x.style.fontsize = "17px"; x.style.color="#03c1cb"; } else{ x.style.color = "white"; x.style.fontsize ="15px"; } } 

and

function iselementinviewport (el) {       //special bonus using jquery       if (typeof jquery === "function" && el instanceof jquery) {         el = el[0];       }       var rect = el.getboundingclientrect();       return (         rect.top >= 0 &&         rect.left >= 0 &&         rect.bottom <= (window.innerheight || document.documentelement.clientheight) && /*or $j(window).height() */         rect.right <= (window.innerwidth || document.documentelement.clientwidth) /*or $j(window).width() */       );     }  // url change on clicking $(document).ready(function () {     $(".scroll").click(function (e) {         e.preventdefault();         var section = this.href,             sectionclean = section.substring(section.indexof("#"));          $("html, body").animate({             scrolltop: $j(sectionclean).offset().top         }, 1000, function () {             window.location.hash = sectionclean;         });      }); }); // listen scroll event     $(document).on("scroll", function() {       console.log("onscroll event fired...");       // check if anchor elements visible       $(".anchor").each(function (idx, el) {         if ( iselementinviewport(el) ) {           // update url hash           if (window.history.pushstate) {             var urlhash = "#" + $j(el).attr("id");             window.history.pushstate(null, null, urlhash);           }         }       });     }); 

and html code

<a href="#home" id="start1" class="scroll" style="text-decoration:none;position:absolute;right:450px;top:37px;font-weight:bold;color:white;font-size:15px;z-index:200;transition:0.5s"  onmouseover="big(this)" onmouseout="small(this)">home</a> 

please me out

you made href color white not visible. change background color dark color

<!doctype html>  <head>   <meta charset="utf-8">    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">   <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">   <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>   <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">    <style>      body {background-color:lightgray}   </style> </head> <body>    <a href="#home" id="start1" class="scroll" style="text-decoration:none;position:absolute;right:450px;top:37px;font-weight:bold;color:white;font-size:15px;z-index:200;transition:0.5s"  onmouseover="big(this)" onmouseout="small(this)">home</a> <script>    function big(x){      console.log(x.id);      var x = document.getelementbyid(x.id);    x.style.fontsize = "17px";    x.style.color="#03c1cb";    }    function small(x){    var y=location.hash;    if(x.href== y){    x.style.fontsize = "17px";    x.style.color="#03c1cb";    }    else{    x.style.color = "white";    x.style.fontsize ="15px";    }  }    </script> </body> </html> 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -