Blog

  • Enabling in Browsers

    Enabling JavaScript

    All modern browsers come with built-in support for JavaScript, and it has enabled JavaScript by default. Frequently, you may need to enable or disable this support manually. This chapter explains how to turn JavaScript support on and off in your browsers: Chrome, Microsoft Edge, Firefox, Safari, and Opera.

    JavaScript in Chrome

    Here are the steps to turn on or turn off JavaScript in Chrome −

    • Click the Chrome menu at the top right-hand corner of your browser.
    • Select the Settings option.
    • Click on the Privacy and Security tab from the left sidebar.
    • Click Show advanced settings at the end of the page.
    • Next, click on the Site Settings tab.
    • Now, scroll to the bottom of the page, and find the content section. Click on the JavaScript tab in the content section.
    • Here, you can select a radio button to turn JavaScript on or off.

    Also, you can add the URLS of the custom website to block and unblock JavaScript on particular websites.

    JavaScript in Microsoft Edge

    Here are simple steps to turn on or turn off JavaScript in your Microsoft Edge −

    • Click Edge menu (three dots) at top right-hand corner of the edge browser.
    • Follow More Tools Internet Options from the menu.
    • Select Security tab from the dialog box.
    • Click the Custom Level button.
    • Scroll down till you find Scripting option.
    • Select Enable radio button under Active scripting.
    • Finally click OK and come out.

    To disable JavaScript support in your Microsoft Edge, you need to select Disable radio button under Active scripting.

    JavaScript in Firefox

    Here are the steps to turn on or turn off JavaScript in Firefox −

    • Open a new tab type about: config in the address bar.
    • Then you will find the warning dialog. Select Ill be careful, I promise!
    • Then you will find the list of configure options in the browser.
    • In the search bar, type javascript.enabled.
    • There you will find the option to enable or disable javascript by right-clicking on the value of that option select toggle.
    • If javascript.enabled is true, it converts to false upon clicking toggle. If javascript is disabled, it gets enabled upon clicking toggle.

    JavaScript in Safari

    When you install the Safari web browser, JavaScript comes installed by default. If you have disabled it and want to enable it, follow the steps below.

    • Click on the safari menu from the top-left corner.
    • Select the preferences in the dropdown menu. It will open a new window.
    • Open the security tab.
    • Check the Enable JavaScript checkbox in the web content section to enable the javascript. You can disable the JavaScript by unchecking the checkbox.
    • Now, close the preference window and reload the web page.

    JavaScript in Opera

    Here are the steps to turn on or turn off JavaScript in Opera −

    • Follow Tools Preferences from the menu.
    • Select the Advanced option from the dialog box.
    • Select Content from the listed items.
    • Select Enable JavaScript checkbox.
    • Finally, click OK and come out.

    To disable JavaScript support in your Opera, you should not select the enable JavaScript checkbox.

    JavaScript in Brave

    The Brave is well-known for its security and privacy. So, It doesnt allow us to disable the JavaScript permanently, but we can disable the JavaScript for the particular website by following the below steps.

    • Open the website URL to disable the browser for it.
    • Now, Click on the Brave Shields icon in the address bar.
    • Find the Scripts option in the Shields panel.
    • The default value of the Scripts is Allow Scripts. If you want to disable JavaScript, choose the “Block Scripts” option.

    Warning for Non-JavaScript Browsers

    If you have to do something important using JavaScript, then you can display a warning message to the user using <noscript> tags.

    You can add a noscript block immediately after the script block as follows −

    <html><head><script>
    
      document.write("Hello World!")&lt;/script&gt;&lt;noscript&gt;
    Sorry...JavaScript is needed to go ahead.</noscript></head><body></body></html>

    Now, if the user’s browser does not support JavaScript or JavaScript is not enabled, then the message from </noscript> will be displayed on the screen.

  • Features

    JavaScript Features

    JavaScript is a highly popular and widely-used programming language for web development. It has a variety of features that make it powerful and flexible. Some of these features include being dynamic, lightweight, interpreted, functional, and object-oriented.

    Many open-source JavaScript libraries are available, facilitating the utilization of JavaScript in both frontend as well as backend development. Let’s highlight some of the key features of JavaScript.

    Easy Setup

    We dont need a particular editor to start writing the JavaScript code. Even anyone can write JavaScript code in NotePad. Also, JavaScript can be executed in the browser without any interpreter or compiler setup.

    You can use the <script > tag to add JavaScript in the HTML file. However, it also allows you to add JavaScript to the web page from the external JavaScript file, having ‘.js‘ extension.

    Browser Support

    All browsers support JavaScript, as all modern browser comes with the built-in JavaScript execution environment.

    However, you can also use the window object to check whether the browser supports JavaScript or its particular feature.

    Dom Manipulation

    JavaScript allows developers to manipulate the webpage elements. Also, you can control the browser.

    It contains the various methods to access the DOM elements using different attributes and allows to customize the HTML elements.

    Event Handling

    JavaScript allows you to handle the events used to interact with the web page.

    For example, you can detect the mouse click on a particular HTML element using JavaScript and interact with the HTML element.

    Some other events also exist, like detecting the scrolling behavior of web page, etc. We will explore all events in the JavaScript events chapter.

    Dynamic Typing

    JavaScript decides the type of variables at runtime. So, we dont need to care about variable data type while writing the code, providing more flexibility to write code.

    Also, you can assign the values of the different data types to a single variable. For example, if you have stored the number value of a particular variable, you can update the variables value with the string.

    Functional Programming

    JavaScript supports the functional programming. In JavaScript, you can define the first-class function, pure functions, closures, higher-order functions, arrow funcitons, function expresions, etc.

    It mostly uses the functions as a primary building blocks to solve the problem.

    Cross-platform Support

    Each operating system and browser support JavaScript. So, it is widely used for developing websites, mobile applications, games, desktop applications, etc.

    Object-oriented Programming

    JavaScript contains the classes, and we can implement all object-oriented programming concepts using its functionality.

    It also supports inheritance, abstraction, polymorphism, encapsulation, etc, concepts of Object-oriented programming.

    Built-in Objects

    JavaScript contains built-in objects like Math and Date. We can use a Math object to perform mathematical operations and a Date object to manipulate the date easily.

    However, you can also manipulate the functionality of the built-in object.

    Object Prototypes

    In JavaScript, everything is an object. For example, array, function, number, string, boolean, set, map, etc. are objects.

    Each object contains the prototype property, which is hidden. You can use the prototype property to achive inheritance or extend the functionality of class or object, by other objects functionality.

    Global Object

    JavaScript contains the global object to access the variables which are available everywhere.

    To access global variables in the browser, you can use the window object, and in Node.js, you can use the ‘global’ keyword to access global variables.

    Recently, globalThis keyword is introduced to access the global variables, and which is supported by the most runtime environments.

    Built-in Methods

    JavaScript also contains the built-in methods for each object. Developers can use the built-in methods to write efficient and shorter codes.

    For example, the Array object contains the filter() method to filter array elements and the sort() method to sort the array. The String object contains the replace() method to replace text in the string, the trim() method to remove whitespaces from the string, etc.

    Modular Programming

    JavaScript allows you to write the code in different modules and connect them with the parent module. So developers can write maintainable code.

    By writing the code in a separate module, you can reduce the complexity of the code and reuse each module whenever you require.

    JSON

    JSON stands for JavaScript object notation. It is a widely used data format to exchange data between two networks. For example, server and client.

    JavaScript also supports the JSON format to store the data.

    Asynchronous Programming

    JavaScript is a single-threaded programming language. To execute your code faster, you can use asynchronous programming.

    You can use promises in JavaScript to write asynchronous code, allowing us to handle multiple tasks asynchronously.

    Event-driven Architecture

    The event-driven architecture of JavaScript allows developers to create interactive and responsive web applications by handling a large user base concurrently.

    Due to the vast features and applications of JavaScript, the front end of Facebook is built on JavaScript. Netflix is built using the ReactJS framework of JavaScript. Similarly, Amazon, PayPal, Airbnb, LinkedIn, Twitter, etc., are also built using JavaScript.

    Server-side Support

    The Node.js runtime environment of JavaScript is widely used to create the backend of the application, as javaScript can also be used to create servers. It allows you to create a scalable backend for the application.

  •  Overview

    What is JavaScript?

    JavaScript is a dynamic computer programming language. It is lightweight and most commonly used as a part of web pages, whose implementations allow client-side script to interact with the user and make dynamic pages. It is an interpreted programming language with object-oriented capabilities.

    JavaScript is a single-threaded programming language that we can use for client-side or server-side development. It is a dynamically typed programming language, which means that we dont care about variable data types while writing the JavaScript code. Also, it contains the control statements, operators, and objects like Array, Math, Data, etc.

    JavaScript was first known as LiveScript, but Netscape changed its name to JavaScript, possibly because of the excitement being generated by Java. JavaScript made its first appearance in Netscape 2.0 in 1995 with the name LiveScript. The general-purpose core of the language has been embedded in Netscape and other web browsers.

    The ECMA-262 Specification defined a standard version of the core JavaScript language.

    • JavaScript is a lightweight, interpreted programming language.
    • Designed for creating network-centric applications.
    • Complementary to and integrated with Java.
    • Complementary to and integrated with HTML.
    • Open and cross-platform

    History of JavaScript

    JavaScript is developed by Brendan Eich, a computer scientist and programmer at Netscape Communications Corporation. The initial name of the JavaScript was the ‘Mocha’. After that, it changed to ‘LiveScript’, and then ‘JavaScript’.

    Between 1996 and 1997, the European Computer Manufacturers Association (ECMA) standardized JavaScript. After that, 3 revisions of the JavaScript have been done.

    In ES5 (2009), Node.js was introduced to use JavaScript as a server-side language. The ES6 (2015) was a significant revision of JavaScript, introducing advanced features into JavaScript.

    Currently, JavaScript has reached the version ES14. ES14 (ECMAScript 2023) the 14th version, was released in June 2023.

    Client-Side JavaScript

    Client-side JavaScript is the most common form of the language. The script should be included in or referenced by an HTML document for the code to be interpreted by the browser.

    It means that a web page need not be a static HTML but can include programs that interact with the user, control the browser, and dynamically create HTML content.

    The JavaScript client-side mechanism provides many advantages over traditional CGI server-side scripts. For example, you might use JavaScript to check if the user has entered a valid e-mail address in a form field.

    The JavaScript code is executed when the user submits the form, and only if all the entries are valid they would be submitted to the Web Server.

    JavaScript can be used to trap user-initiated events such as button clicks, link navigation, and other actions that the user initiates explicitly or implicitly.

    The Popular client-side libraries for JavaScript development are ReactJS, NextJS, Vue JS, Angular JS, etc.

    Server-Side JavaScript

    In the early days, JavaScript was used for front-end development to add behaviors to HTML pages. Since 2009, JavaScript is also used as a server-side programming language to build scalable and dynamic web applications.

    Node.js is one of the best and most popular JavaScript runtime environments for building the server of applications using JavaScript. Using Node.js, we can execute the JavaScript code outside the browser and manage the server task. The server tasks can be an interaction with the database, APIS, file handling, or maybe network communication. Due to the event-driven architecture of Node.js, it is faster than other server-side programming languages.

    Advantages of JavaScript

    The merits of using JavaScript are −

    • Less server interaction − You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server.
    • Immediate feedback to the visitors − They don’t have to wait for a page reload to see if they have forgotten to enter something.
    • Increased interactivity − You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard.
    • Richer interfaces − You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.

    Limitations of JavaScript

    We cannot treat JavaScript as a full-fledged programming language. It lacks the following important features −

    • Client-side JavaScript does not allow the reading or writing of files. This has been kept for security reasons.
    • JavaScript cannot be used for networking applications because no such support is available.
    • JavaScript doesn’t have any multi-threading capabilities.

    Imperative vs. Declarative JavaScript

    The imperative and declarative is a programming paradigm, and JavaScript follows both.

    • Imperative JavaScript − In imperative JavaScript, we write code in the manner that the code describes the steps to get the output. So, we are concerned about the code execution flow and output both. For example, to sum all array elements, if we write code for loop, it explains each step to get the sum.
    • Declarative JavaScript − In declarative JavaScript, we don’t need to worry about execution flow, but we should get the correct output at the end. For example, we use a built-in array.reduce() method to get a sum of array elements. Here, we dont concern about how reduce() method is implemented in the library.

    JavaScript Development Tools

    One of the major strengths of JavaScript is that it does not require expensive development tools. You can start with a simple text editor such as Notepad. Since it is an interpreted language inside the context of a web browser, you don’t even need to buy a compiler.

    Here are various free tools which can be helpful while developing applications with JavaScript.

    • Visual Studio Code (VS Code) − The VS Code is a code editor used by most developers to write JavaScript code. It is feature rich and contains various extensions that can increase the productivity of any developer.
    • Chrome dev tools − Programmers may use the Chrome dev tools to debug the JavaScript code. However, they can use the debugging tool of any browser as most browser comes with it.

    The above 2 tools increase the productivity of the developer for writing the code. Furthermore, you may use other tools like Git for version controlling, Webpack to build your application, etc.

    Where is JavaScript Today?

    In 2015, the ES6 version of JavaScript was launched with significant enhancements, including object-oriented concepts, anonymous functions, template literals, etc. In June 2023, the ES14 (ECMAScript 2023), the 14th version of JavaScript was launched.

  • Roadmap

    This Roadmap will guide you to master JavaScript. You will learn core concepts, advanced techniques, and best practices by following mentioned topics. This step-by-step path will help you as a beginner.

    What is a Tutorial Roadmap?

    Tutorial Roadmap typically covers the journey from beginner to advanced user, including key concepts, practical applications, and best practices.

    JavaScript Roadmap

    Master JavaScript from beginner to expert with our comprehensive 2024 roadmap. Learn about essential DOM manipulation, async programming, and best practices. Includes practical examples, learning resources, and a structured timeline for becoming a HTML expert.

    JavaScript RoadmapJavaScript OverviewJavaScript Variables

    JavaScript Data TypesJavaScript VersionsJavaScript History

    var

    let

    const

    Variable Declaration

    Variable Scope

    Block

    Function

    Global

    Hoisting

    string

    undefined

    number

    bigInt

    boolean

    null

    Symbol

    Primitive Data Types

    Objects

    typeof Operator

    Object Prototype

    Object Constructor

    JavaScript Type Casting

    Type Conversions

    Implicit Type Casting 

    Explicit Type Casting

    Data Structure

    Structure Data 

    Keyed Collections

    Indexed collections

    JSON

    Map

    WeakMap

    Set

    WeakSet

    Typed Array

    Array

    Loops and Iterations

    All about Loops

    for

    for…of

    do–while

    for…in

    while

    Loop Control

    Control Flow

    Conditional Statement

    Exceptions Handling

    if…else

    switch

    try…catch

    ErrorsExpressions & Operators

    Continue

    Break

    Arithmetic

    Logical

    Bitwise

    Assignment

    Conditional

    typeof

    Nullish Coalescing

    Delete

    Comma

    Grouping

    Yield

    Spread

    Exponentiation

    Precedence

    OperatorsFunctions

    Expressions

    Parameters

    Constructor

    Self-Invoking

    Arrow

    Invocation

    Closures

    Variable Scope

    Global Variables

    Smart Parameters

    All about Functions

    Classes

    JavaScript Cookies

    Cookie Attributes

    Deleting Cookies

    JavaScript BOM

    Window Object

    Document Object

    Screen Object

    History Object

    Navigator Object

    Location Object

    Console Object

    JavaScript Events

    DOM Events

    Mouse Events

    Keyboard Events

    Form Events

    Window/Document Events

    Event Delegation

    Event Bubbling

    Event Capturing

    Custom Events

    Important Keywords

    this

    void

    new

    JavaScript APIs

    Web API

    History API

    Storage API

    Forms API

    Worker API

    Fetch API

    Geolocation API

    HTML DOMJavaScript  Asynchronous JavaScript ModulesJavaScript Questions

    Interview Questions

    Online Quiz

    Online Test

    Mock Test

    Comparison Operator

    How JavaScript Roadmap Can help you?

    This JavaScript roadmap includes essential programming concepts, hands-on coding exercises, and valuable learning resources. Calculate your learning timeline, implement strategic coding practices, and build a solid foundation in JavaScript development with our clear, structured approach.

  • JavaScript Tutorial

    What is JavaScript

    JavaScript is a lightweight, interpreted programming language. It is commonly used to create dynamic and interactive elements in web applications. JavaScript is very easy to implement because it is integrated with HTML. It is open and cross-platform.

    Why to Learn JavaScript?

    JavaScript is a MUST for students and working professionals to become a great Software Engineer, especially when they are working in Web Development Domain. We will list down some of the key advantages of learning JavaScript−

    • JavaScript is the most popular programming language in the world, making it a programmer’s great choice. Once you learn JavaScript, it helps you develop great front-end and back-end software using different JavaScript based frameworks like jQuery, Node.JS, etc.
    • JavaScript is everywhere, it comes installed on every modern web browser and so to learn JavaScript, you really do not need any special environment setup. For example, Chrome, Mozilla Firefox, Safari, and every browser you know as of today, supports JavaScript.
    • JavaScript helps you create really beautiful and crazy fast websites. You can develop your website with a console like look and feel and give your users the best Graphical User Experience.
    • JavaScript usage has now extended to mobile app development, desktop app development, and game development. This opens many opportunities for you as JavaScript Programmer.
    • Due to high demand, there is tons of job growth and high pay for those who know JavaScript. You can navigate over to different job sites to see what having JavaScript skills looks like in the job market.
    • Great thing about JavaScript is that you will find tons of frameworks and Libraries already developed which can be used directly in your software development to reduce your time to market.
    • JavaScript is in all over the world, and companies like Google, Meta, Microsoft, PayPal, LinkedIn, etc. also use JavaScript.
    • Furthermore, JavaScript has more than 1.5 lakh libraries. It is also growing.
    • A huge community of JavaScript is available on the internet with students, developers, and mentors. So anyone can easily get support.

    There could be 1000s of good reasons to learn JavaScript Programming. But one thing for sure, to learn any programming language, not only JavaScript, you just need to code, and code, and finally code until you become an expert.

    JavaScript Applications

    As mentioned before, JavaScript is one of the most widely used programming languages (Front-end as well as Back-end). It has its presence in almost every area of software development. I’m going to list few of them here:

    • Client side validation − This is really important to verify any user input before submitting it to the server and JavaScript plays an important role in validating those inputs at front-end itself.
    • Manipulating HTML Pages − JavaScript helps in manipulating HTML page on the fly. This helps in adding and deleting any HTML tag very easily using JavaScript and modify your HTML to change its look and feel based on different devices and requirements.
    • User Notifications − You can use JavaScript to raise dynamic pop-ups on the webpages to give different types of notifications to your website visitors.
    • Back-end Data Loading − JavaScript provides Ajax library which helps in loading back-end data while you are doing some other processing. This really gives an amazing experience to your website visitors.
    • Presentations − JavaScript also provides the facility of creating presentations which gives website look and feel. JavaScript provides RevealJS and BespokeJS libraries to build a web-based slide presentation.
    • Server Applications − Node JS is built on Chrome’s JavaScript runtime for building fast and scalable network applications. This is an event based library which helps in developing very sophisticated server applications including Web Servers.
    • Machine learning − Developers can use the ML5.js library to complete the task related to machine learning.
    • Game Developments − JavaScript contains multiple libraries and NPM packages to design graphics for the game. We can use HTML, CSS, and JavaScript with libraries to develop the games.
    • Mobile applications − We can use frameworks like React Native to build feature-rich mobile applications.
    • Internet of Things (IoT) − JavaScript is used to add functionality to devices like smartwatches, earbuds, etc.
    • Data visualization − JavaScript contains the libraries like D3.js to visualize the data efficiently. The D3.js is also used to prepare high-quality charts to visualize the data.
    • Cloud computing − We can use JavaScript in serverless computing platforms like Cloudflare and AWS lambda to write and deploy functions on the cloud.

    This list goes on, there are various areas where millions of software developers are happily using JavaScript to develop great websites and other software.

    Basic JavaScript Example

    Below is a basic JavaScript example that will print “Getting started with JavaScript tutorial” on the webpage. You can edit this example and execute it by clicking on the “Edit & Run” button.

    <script>
    
    document.write("Getting started with JavaScript tutorial");&lt;/script&gt;</pre>

    Online JavaScript Editor

    We have provided JavaScript Online Editor which helps you to Edit and Execute the code directly from your browser. Try to click the icon run button to run the following JavaScript code to print conventional "Hello, World!".

    Open JS Editor to practice your scripts hereOnline JavaScript Editor

    Below code box allows you to change the value of the code. Try to change the value of Hello, World! and run it again to verify the result.

    <html><head><title>The JavaScript Example</title></head><body><script language ="javascript" type ="text/javascript">
    
         document.write("Hello World!")&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;</pre>

    Who Should Learn JavaScript?

    This JavaScript tutorial has been prepared for student as well as working professionals to help them understand the basic functionality of JavaScript to build dynamic web pages and web applications.

    Prerequisites to Learn JavaScript

    For this JavaScript tutorial, it is assumed that the reader has prior knowledge of HTML coding. It would help if the reader had prior exposure to object-oriented programming concepts and a general idea of creating online applications.

    JavaScript Online Quizzes

    This Javascript tutorial helps you prepare for technical interviews and certification exams. We have provided various quizzes and assignments to check your learning level. Given quizzes have multiple choice type of questions and their answers with short explanation.

    Following is a sample quiz, try to attempt any of the given answers:Show Answer

    Q 1 - Which of the following is correct about JavaScript?

    A - JavaScript is a lightweight, interpreted programming language.

    B - JavaScript has object-oriented capabilities that allows you to build interactivity into otherwise static HTML pages.

    C - The general-purpose core of the language has been embedded in Netscape, Internet Explorer, and other web browsers.

    D - All of the above.

    Start your online quiz Start Javascript Quiz.

    JavaScript Jobs

    In the world, there are 15+ Million active JavaScript developers. Still, there is a shortage of skilled JavaScript developers. So, it could be a great chance for you to start your career as a JavaScript developer.

    Here are the most popular companies offering the role of JavaScript developer. You can land as an employee with a high package after pursuing your career as a JavaScript developer.

    • Amazon
    • Google
    • Microsoft
    • Apple
    • Adobe
    • Facebook
    • PayPal
    • Many more...

    Careers Opportunities in JavaScript

    There are several career paths that you can choose after learning JavaScript. Here, we have listed some of them.

    • Front-end developer
    • Back-end developer
    • Full-stack developer
    • Web developer
    • Game developer
    • Mobile App developer
    • DevOps Engineer
    • Many other roles

    JavaScript Frameworks and Libraries

    JavaScript frameworks are used to develop a whole application. It defines the structure of your application.

    The framework can have pre-built components and other functionalities that can help you reuse the code of the application, improve code readability, and avoid duplicity.

    Here, we have explained the most popular JavaScript frameworks which you can use for website development, app development, backend development, etc.

    • React
    • Angular
    • Vue.js
    • Ember.js
    • Node.js
    • Backbone.js
    • Next.js
    • Mocha
    • Meteorjs
    • Polymer

    In JavaScript, a library is a set of pre-defined functions, classes, methods, objects, etc. You can import the library in your JavaScript code by using the CDN or downloading it locally. After adding the library to the project, you can use the library's pre-written functions, classes, etc., in the code.

    Here, we have given a list of the most popular JavaScript libraries.

    • jQuery
    • Axios
    • Chart.js
    • D3.js
    • Socket.io
    • Underscore.js
    • Lodash
    • Three.js

    JavaScript Certification

    Get certified in JavaScript to boost your skills and careerGet certified

    JavaScript Practice

    To practice and quick revision of JavaScript, we also provided:

    • JavaScript Interview Questions
    • JavaScript Quick Guide
    • JavaScript Cheatsheet
    • JavaScript Built-in Functions

    JavaScript Articles

    You can explore a set of JavaScript Articles at JavaScript Articles.

    Frequently Asked Questions about JavaScript

    There are some very Frequently Asked Questions(FAQ) about JavaScript, this section tries to answer them briefly.What is JavaScript?

    chevron

    Name some of the JavaScript features.

    chevron

    What are the advantages of using JavaScript?

    chevron

    What are disadvantages of using JavaScript?

    chevron

    Is JavaScript a case-sensitive language?

    chevron

    Which is the best place to learn JavaScript?

    chevron

    What are some backend JavaScript frameworks?

  • Live Search Filter

    Concepts Used: keyup(), filtering elements

    Features:

    • Search through a list dynamically
    <!DOCTYPE html>
    <html>
    <head>
      <title>Live Search</title>
      <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    </head>
    <body>
      <h2>Live Search Filter</h2>
      <input type="text" id="search" placeholder="Search...">
      <ul id="list">
    
    &lt;li&gt;Apple&lt;/li&gt;
    &lt;li&gt;Banana&lt;/li&gt;
    &lt;li&gt;Orange&lt;/li&gt;
    &lt;li&gt;Mango&lt;/li&gt;
    &lt;li&gt;Grapes&lt;/li&gt;
    </ul> <script>
    $(document).ready(function(){
      $("#search").keyup(function(){
        let value = $(this).val().toLowerCase();
        $("#list li").filter(function(){
          $(this).toggle($(this).text().toLowerCase().indexOf(value) &gt; -1);
        });
      });
    });
    </script> </body> </html>

    Explanation:

    • .keyup() detects input changes.
    • .filter() checks list items dynamically.
  • Light/Dark Mode Switch

    Concepts Used: toggleClass()

    Features:

    • Switch page between light & dark theme
    <!DOCTYPE html>
    <html>
    <head>
      <title>Dark Mode Toggle</title>
      <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
      <style>
    
    body { transition: 0.5s; }
    .dark { background: black; color: white; }
    </style> </head> <body> <h2>Dark Mode Example</h2> <button id="toggle">Toggle Dark Mode</button> <script>
    $(document).ready(function(){
      $("#toggle").click(function(){
        $("body").toggleClass("dark");
      });
    });
    </script> </body> </html>

    Explanation:

    • .toggleClass() switches between normal and dark theme.
  • Weather App (API + jQuery AJAX)

    Concepts Used: $.ajax(), API call

    Features:

    • Get weather by city using OpenWeatherMap API (free key required).
    <!DOCTYPE html>
    <html>
    <head>
      <title>Weather App</title>
      <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    </head>
    <body>
      <h2>Weather App</h2>
      <input type="text" id="city" placeholder="Enter City">
      <button id="getWeather">Get Weather</button>
      <p id="weather"></p>
    
      <script>
    
    $(document).ready(function(){
      $("#getWeather").click(function(){
        let city = $("#city").val();
        let apiKey = "YOUR_API_KEY"; // &lt;-- Replace with your OpenWeatherMap key
        $.ajax({
          url: https://api.openweathermap.org/data/2.5/weather?q=${city}&amp;amp;appid=${apiKey}&amp;amp;units=metric,
          method: "GET",
          success: function(data){
            $("#weather").text(Temperature: ${data.main.temp}°C, ${data.weather&amp;#91;0].description});
          },
          error: function(){
            $("#weather").text("City not found!");
          }
        });
      });
    });
    </script> </body> </html>

    Explanation:

    • Uses $.ajax() to fetch weather JSON data.
    • Displays temperature & description dynamically.
  • Drag & Drop Boxes

    Concepts Used: jQuery UI (draggable, droppable)

    Features:

    • Drag a box and drop into target
    <!DOCTYPE html>
    <html>
    <head>
      <title>Drag Drop Example</title>
      <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
      <script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script>
      <style>
    
    #drag { width: 100px; height: 100px; background: skyblue; margin: 20px; }
    #drop { width: 150px; height: 150px; background: lightgray; margin: 20px; }
    </style> </head> <body> <h2>Drag and Drop</h2> <div id="drag">Drag Me</div> <div id="drop">Drop Here</div> <script>
    $(document).ready(function(){
      $("#drag").draggable();
      $("#drop").droppable({
        drop: function(event, ui){
          $(this).css("background","lightgreen").text("Dropped!");
        }
      });
    });
    </script> </body> </html>

    Explanation:

    • draggable() makes item movable.
    • droppable() detects drop event.
  • Calculator

    Concepts Used: Event handling, DOM manipulation

    Features:

    • Basic calculator with +, -, ×, ÷
    <!DOCTYPE html>
    <html>
    <head>
      <title>jQuery Calculator</title>
      <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
      <style>
    
    #calc { width: 200px; margin: 20px; }
    button { width: 45px; height: 45px; margin: 2px; }
    #result { width: 185px; height: 40px; margin-bottom: 10px; text-align: right; font-size: 18px; }
    </style> </head> <body> <h2>Calculator</h2> <div id="calc">
    &lt;input type="text" id="result" readonly&gt;&lt;br&gt;
    &lt;button class="btn"&gt;7&lt;/button&gt;
    &lt;button class="btn"&gt;8&lt;/button&gt;
    &lt;button class="btn"&gt;9&lt;/button&gt;
    &lt;button class="btn"&gt;/&lt;/button&gt;&lt;br&gt;
    &lt;button class="btn"&gt;4&lt;/button&gt;
    &lt;button class="btn"&gt;5&lt;/button&gt;
    &lt;button class="btn"&gt;6&lt;/button&gt;
    &lt;button class="btn"&gt;*&lt;/button&gt;&lt;br&gt;
    &lt;button class="btn"&gt;1&lt;/button&gt;
    &lt;button class="btn"&gt;2&lt;/button&gt;
    &lt;button class="btn"&gt;3&lt;/button&gt;
    &lt;button class="btn"&gt;-&lt;/button&gt;&lt;br&gt;
    &lt;button class="btn"&gt;0&lt;/button&gt;
    &lt;button class="btn"&gt;.&lt;/button&gt;
    &lt;button class="btn"&gt;=&lt;/button&gt;
    &lt;button class="btn"&gt;+&lt;/button&gt;
    </div> <script>
    $(document).ready(function(){
      let input = "";
      $(".btn").click(function(){
        let val = $(this).text();
        if(val === "="){
          try {
            input = eval(input).toString();
          } catch {
            input = "Error";
          }
        } else {
          input += val;
        }
        $("#result").val(input);
      });
    });
    </script> </body> </html>

    Explanation:

    • Stores expression as string.
    • eval() evaluates input (simple demo).
    • Updates display with .val().