Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Create Dark And Light Mode Website Using jQuery

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <title>How To Create Dark And Light Mode Website Using jQuery - Techsolutionstuff</title>        
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <style> 
        body{         
        text-align:center; 
        } 
        img{ 
            height:140px; 
            width:140px;  
        } 
        h1{ 
        color: #000; 
        margin-top: 50px;
        } 
        .mode { 
            float:right; 
            margin-top: 20px;
            margin-right: 20px;
        } 
        .change { 
            cursor: pointer; 
            border: 1px solid #555; 
            border-radius: 10%; 
            width: 20px; 
            text-align: center; 
            padding: 8px; 
            margin-left: 8px; 
        } 
        .dark{ 
            background-color: #222; 
            color: #e6e6e6; 
        }
      .dark h1{ 
        color: #fff;         
        } 
    </style> 
</head>   
<body> 
    <div class="mode"> 
        <b>Select Mode:</b><span class="change">OFF</span> 
    </div><br>     
    <div> 
      <h1><i>Techsolutionstuff</i></h1> 
        <p><i>We Give Best Tech Stuff for You</i></p> 
        <h3>Light Mode and Dark Mode</h3>                    
        <p> 
            Click on the switch on <b>Top Right Corner</b>
            to move to <b>Dark Mode</b> and <b>Light Mode.</b>
        </p> 
    </div>       
    <script> 
        $( ".change" ).on("click", function() { 
            if( $( "body" ).hasClass( "dark" )) { 
                $( "body" ).removeClass( "dark" ); 
                $( ".change" ).text( "OFF" ); 
            } else { 
                $( "body" ).addClass( "dark" ); 
                $( ".change" ).text( "ON" ); 
            } 
        }); 
    </script> 
</body>   
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: canvas setup 
Javascript :: javascript string length 
Javascript :: javascript split a string 
Javascript :: on drop, drag, dragover event 
Javascript :: mongoos populate a ref 
Javascript :: global catch in javascript 
Javascript :: native module rnc_asyncsqlitedbstorage tried to override asyncstorage module 
Javascript :: how to change the text of a paragraph 
Javascript :: caching in javascript 
Javascript :: puppeteer block request javascript 
Javascript :: JavaScript Object Accessors 
Javascript :: javascript split method 
Javascript :: flutter inject javascript in flutter webview 
Javascript :: print stuff in console javascript 
Javascript :: string properties in javascript 
Javascript :: run the for loop in the html elements and show the limited elements in javascript 
Javascript :: vue-router beforeeach 
Javascript :: how to call function on every keypress in jquery 
Javascript :: mobile nav react npm 
Javascript :: javascript array foreach 
Javascript :: javascript pipe function 
Javascript :: js array map skip element 
Javascript :: what is package.json 
Javascript :: js key event 
Javascript :: exclude vales from array in js 
Javascript :: how to disable button if errors object isnt empty in react hook form 
Javascript :: form- text area react 
Javascript :: map and filter js 
Javascript :: sort in javascript 
Javascript :: why to use arrow functions over normal function 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =