Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Front End Technology Articles
Page 19 of 652
What is the difference between closure and nested functions in JavaScript?
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 MoreHow to turn a String into a JavaScript function call?
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 MoreHow can I pop-up a print dialog box using JavaScript?
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 MoreHow can I delete all cookies with JavaScript?
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 MoreHow to detect all active JavaScript event handlers?
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 MoreHow to load external website into an <iframe> using jQuery?
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 MoreHow to get the value of div content using jQuery?
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 MoreHow to get content of div which contains JavaScript script blocks?
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 MoreWhat is the difference between $(window).load() and $(document).ready() functions in jQuery?
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 MoreHow to create a chart from JSON data using Fetch API in JavaScript?
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