add active class on open page using javascript

Solutions on MaxInterview for add active class on open page using javascript by the best coders in the world

showing results for - "add active class on open page using javascript"
Rafael
12 Feb 2017
1<!DOCTYPE html>
2<html>
3    <head>
4        <meta name="viewport" content="width=device-width, initial-scale=1">
5        <style>
6            .active {
7            padding: 5px;
8            background-color: #20BF55;
9            color: white;
10            }
11        </style>
12    </head>
13    <body>
14        <div id="text" onclick="makeActive()">
15            Click to make Active
16        </div>
17        <script>
18            function makeActive() {
19               var element = document.getElementById("text");
20               element.classList.add("active");
21               element.innerHTML="This is Active";
22            }
23        </script>
24    </body>
25</html>
26
Mads
17 Aug 2019
1<script>
2  function func(){
3   document.getElementById('div').classList.add('active');
4  }
5</script>
6
7<button onclick='func()'>Click</button>
8<div id="div">
9  This element gets 'active' class.
10</div>
Jan
17 Aug 2016
1    jQuery(function($) {
2     var path = window.location.href; // because the 'href' property of the DOM element is the absolute path
3     $('ul a').each(function() {
4      if (this.href === path) {
5       $(this).addClass('active');
6      }
7     });
8    });
queries leading to this page
add active class on clickjavascript how to add active class on clickadd active class to clickedjavascript add active class to linksadd active class on click javascriptadd active class onclick javascript learn how to add an active class to the current element with javascript add active class to current elementadd active class on click buttononclick active classhow to put active class on the element under one element in html from javascripton click active class jshow to add active class on click using javascriptadd active class javascripthow to add active class on click in html css and javascripthow add active class jaqaryjavascript addclass 28 22active 22 29set class active jsclass active javascripton click add active classadding active class on clickjs set active classfunction add class activeset active class on clickassign active class on clickhow to add active class onclickon click to add class active jsadd active class on click css with jsjavascript add active class to current pagejs add active class onclickadd active class to div on clickjavascript code to set active classbutton click class active jsadd active to class jsactive class in javascriptsimple javascrip to add a class on 3aactive csshow to add active class to current element javascripton click active class addonclick add active classadd active class onclick typescriptadd active class on click buttonsonclick toggle active class javascriptactive class jsjavascript on click add class activeadding an active class onclick cssadd active class on button clicksimple javascrip to add a class on active csschange active class on click in javascriptactive class by javascriptadd active class on open page using javascripthow to put active class on the element under one leementin html from javascriptjs on click class activesimple active class json click add active class jswhen click add class active javascriptonclick add active class on div js active class using javascriptactive class js on clickjs function active class on clickadding active class html css javascriptadd active class for 4 seconds javascripthow to put active class on the element under in html from javascriptonclick add class activeactive class javascripthow to set onclick active class in jsusing active class in javascriptadd active class to div javascriptadding active class javascriptjs onclick add class activehow to set active class on clickmake class active onclickhow to add active class in javascriptactive class css html jshow to add active class on clickadd active class using javascriptadd active class to button onclickonclick add active class in knockout jsgive active class on clickadd active class to li onclick javascriptassign active to button click with javascriptactive class to current element using javascriptchange active class onclick javascriptonclick add active class javascriptactive class with javascriptjavascript class activejavascript add active class to current click eventon click set active classadd active class on open page using javascript