Author: Krishnaa

How to Replace Content in Javascript

HTML: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="style.css"> <title>Document</title> </head> <body> <div class="container"> <div> <button id="btnText">Text</button> <button id="btnHtml">HTML</button> </div> <div id="content"> <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Consequatur, odio pariatur quam nostrum eos deleniti maiores rerum neque obcaecati similique est quae illo nihil

How to Add and Remove Event Listener in Javascript

HTML: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="style.css"> <title>Document</title> </head> <body> <div> <button id="add">Add</button> <button id="remove">Remove</button> <h1>Output</h1> </div> <script src="script.js"></script> </body> </html>   CSS: body { text-align: center; } div { display: inline-block; } button { padding: 10px 20px; }   Javascript: let btnAdd =

How to Remove First and Last Element in Array in Javascript

In this video tutorial, you will learn how to remove first and last element in array in javascript. HTML: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="style.css"> <title>Document</title> </head> <body> <div> <button id="first">First</button> <button id="last">Last</button> <ul></ul> </div> <script src="script.js"></script> </body> </html>   CSS: body { text-align:

How to Get Number of Characters in a String in Javascript

In this video tutorial, you will learn how to get number of characters in a string in javascript.   HTML: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="style.css"> <title>Document</title> </head> <body> <div> <input type="text"> <button>Get</button> <h1>Result</h1> </div> <script src="script.js"></script> </body> </html>   CSS: body { text-align: