Event Bubbling and Capturing

The DOM has two ways for objects to detect events: from the top down, and from the bottom up. The first method is known as event capture, the second is called event bubbling. Event capturing When you use event capturing | | —————| |—————– | element1 | | | | ———–| |———– | | |element2 \ / […]

Read More

Overloading vs Overriding in JavaScript

JavaScript does not support overloading. JavaScript supports overriding, so if you define two functions with the same name, the last one defined will override the previously defined version and every time a call will be made to the function, the last defined one will get executed. Example: <script type=”text/javascript”> function sum(x, y, z) { return […]

Read More

jsGrid in jQuery

jsGrid is a lightweight client-side data grid control based on jQuery. It supports basic grid operations like inserting, filtering, editing, deleting, paging, and sorting. jsGrid is flexible and allows to customize its appearance and components. jsGrid CDN:- jsGrid is available on cdnjs. Here is the CDN links available: <link type=”text/css” rel=”stylesheet” href=”https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid.min.css” /> <link type=”text/css” […]

Read More

Method Chaining in Javascript

Method chaining is a technique that can be used to simplify code in scenarios that involve calling multiple functions on the same object consecutively. This chain is just a single expression. It’s easy enough to break this chain down and make each of the calls into separate expressions, but then it would obviously not be […]

Read More

How to get Value from usercontrol to aspx page in Javascript

In this post i will show how to get value of a textbox of user control in Asp.net page where that user control is registered.This question is asked in my many interview so come to the example lets first create a user control with the name of Test.  <%@ Control Language=”C#” AutoEventWireup=”true” CodeFile=”Test.ascx.cs” Inherits=”Test” %> […]

Read More

Clear JS and CSS cache in jQuery

You can’t clear client system browser cache using jQuery or javascript but you can clear your application cache pragmatically. $(‘.button’).click(function() { $.ajax({ url: “”, context: document.body, success: function(s,x){ $(‘html[manifest=saveappoffline.appcache]’).attr(‘content’, ”); $(this).html(s); } }); }); or you have to disable the cache control <meta http-equiv=’cache-control’ content=’no-cache’> <meta http-equiv=’expires’ content=’0′> <meta http-equiv=’pragma’ content=’no-cache’>

Read More

Include a JavaScript file in another JavaScript file

JavaScript can not import, include, or require but you can achieve this through some different way like by using Ajax loading. Load an additional script with an ajax call method and then use eval. This is the most straightforward way, but you can do it on same domain only because of the JavaScript sandbox security […]

Read More

JavaScript closures

JavaScript variables can belong to the local or global scope where as Private variables can be made possible with closures. A closure is an inner function that has access to the outer (enclosing) function’s variables—scope chain. The closure has three scope chains: it has access to its own scope (variables defined between its curly brackets), […]

Read More

Disable Cut Copy Paste operation using jQuery

Somtimes we need to disable Cut, Copy, Paste content from textbox in our site due to some reasons(like don’t allow to copy password from password TextBox to Confirm password TextBox). We can implement this functionality with the help of below example. First create two textboxes control  password and  confirm password. <table> <tr><td>Password: </td><td><asp:TextBox ID=”txtPassword” runat=”server”></asp:TextBox></td></tr> […]

Read More

Check whether a CheckBox is checked or not

Here I will show how to Check whether a CheckBox is checked or not with example. Check whether a CheckBox is checked (selected) or not using jQuery <script type=”text/javascript”> $(function () { $(“#btnCheck”).click(function () { var isChecked = $(“#chkbox”).is(“:checked”); if (isChecked) { alert(“CheckBox checked.”); } else { alert(“CheckBox not checked.”); } }); }); </script>

Read More

create objects in JavaScript

There are 3 ways to create object in JavaScript. By object literal By creating instance of Object By Object Constructor Examples object using object literal object={property1:value1,property2:value2…..propertyN:valueN} creating object in JavaScript emp={id:102,name:”Amit Kumar”,salary:19000} document.write(emp.id+” “+emp.name+” “+emp.salary);

Read More