Front End Technology Articles

Page 19 of 652

What is the difference between closure and nested functions in JavaScript?

mkotla
mkotla
Updated on 11-Mar-2026 1K+ Views

JavaScript ClosuresIn JavaScript, all functions work like closures. A closure is a function, which uses the scope in which it was declared when invoked. It is not the scope in which it was invoked.Here’s an example           JavaScriptClosures                       varp = 20;             functiona(){                var p = 40;                b(function(){                   alert(p);             }); ...

Read More

How to turn a String into a JavaScript function call?

Smita Kapse
Smita Kapse
Updated on 11-Mar-2026 568 Views

To turn a string into a JavaScript function call, try to run the following codeExample                    function myFunction(argument) {             alert('My function ' + argument);          }          functionName = 'myFunction';          window[functionName]('is working.');          

Read More

How can I pop-up a print dialog box using JavaScript?

Amit Sharma
Amit Sharma
Updated on 11-Mar-2026 4K+ Views

To pop-up a print dialog box using JavaScript, use the print() method. With the dialog box, you can easily set the printing options like which printer to select for printing.This is the dialog box −ExampleYou can try to run the following code to learn how to print a page −           Click to Print                function display() {             window.print();          }          

Read More

How can I delete all cookies with JavaScript?

Vrundesha Joshi
Vrundesha Joshi
Updated on 11-Mar-2026 1K+ Views

To delete all cookies with JavaScript, you can try to run the following code. Here, we’re using an array and the split() method to get all the cookies and finally delete themExample                    var num = 1;          function addCookie(){             document.cookie = num+" = "+num;             num++;          }          function listCookies(){             var result = document.cookie;             document.getElementById("list").innerHTML = result;          }          function removeCookies() {             var res = document.cookie;             var multiple = res.split(";");             for(var i = 0; i < multiple.length; i++) {                var key = multiple[i].split("=");                document.cookie = key[0]+" =; expires = Thu, 01 Jan 1970 00:00:00 UTC";             }          }                     ADD       LIST COOKIES       REMOVE       Cookies List          

Read More

How to detect all active JavaScript event handlers?

Nishtha Thakur
Nishtha Thakur
Updated on 11-Mar-2026 821 Views

The simplest solution is to use jQuery to detect all active JavaScript event handlers.ExampleYou can try to run the following code to detect active event handlers                          var myEvent = $("#demo");          myEvent.mouseover(function() {});          $.each(myEvent.data("events"), function(i, e) {             alert(i);          });                     Demo Text    

Read More

How to load external website into an <iframe> using jQuery?

Amit D
Amit D
Updated on 11-Mar-2026 39 Views

To load an external HTML into using jQuery, use the attr() method. In that set the source for iframe. You can try to run the following code to learn how to locate external HTML −Example $(document).ready(function(){    $('#iframe').attr('src', 'https://www.qries.com'); });

Read More

How to get the value of div content using jQuery?

Alex Onsman
Alex Onsman
Updated on 11-Mar-2026 27K+ Views

To get the value of div content in jQuery, use the text() method. The text() method gets the combined text contents of all matched elements. This method works for both on XML and XHTML documents.ExampleYou can try to run the following code to get the value of div content using jQuery: $(document).ready(function() {    $("#button1").click(function() {      var res = $('#demo').text();      alert(res);    }); }); This is demo text. Get

Read More

How to get content of div which contains JavaScript script blocks?

Ricky Barnes
Ricky Barnes
Updated on 11-Mar-2026 3K+ Views

To get the content of div which contains JavaScript script blocks, use the html() method. You can try to run the following code to get the content. With html(), get the content of div, which includes the JavaScript script.Example                            $(document).ready(function(){            $("#button1").click(function(){              alert($("#demo").html());              });          });                                This is demo text.                       This is JavaScript                        Get    

Read More

What is the difference between $(window).load() and $(document).ready() functions in jQuery?

David Meador
David Meador
Updated on 11-Mar-2026 4K+ Views

Both the methods are used in jQuery. Let's see what purpose they fulfill. $(window).load() The code which gets included inside $( window ).on( "load", function() { ... }) runs only once the entire page is ready (not only DOM). Note: The load() method deprecated in jQuery version 1.8. It was completely removed in version 3.0. To see its working, add jQuery version for CDN before 3.0. $(document).ready() The ready() method is used to make a function available after the document is loaded. Whatever code you write inside the $( document ).ready() method will run once ...

Read More

How to create a chart from JSON data using Fetch API in JavaScript?

Mayank Agarwal
Mayank Agarwal
Updated on 11-Mar-2026 5K+ Views

In this article, we are going to explore on how to create a chart after fetching the JSON data. To fetch JSON data we use fetch() method of Fetch API. We will first fetch the data and once the data is available we will feed it into the system to create a chart. The Fetch API provides a simple interface for accessing and manipulating HTTP requests and responses.Syntaxconst response = fetch(resource [, init])Parametersresource − This is the resource path from where the data is fetched.init − It defines any extra options such as headers, body, etc.ApproachThe steps can be defined ...

Read More
Showing 181–190 of 6,518 articles
« Prev 1 17 18 19 20 21 652 Next »
Advertisements