Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

How to use Array sort() Method in JavaScript ?

sort() method is used for sorting the items of an array.It sorts the values as strings in alphabetical and ascending order. And sort() method sort alphabetic or numeric. you can take reference of bellow example. <!DOCTYPE html> &l...

How to add and remove a class on click event

hii, Today i am sharing a blog on How to add and remove a class on click event in javascript. First of all you need to either download few plugins or just copy and paste the below link inside head tag. <script src="https://ajax.google...

HTML5 Web Worker

A web worker is basically a javascript code that runs in the background. It does not effect the performance of the Page. Usually When we run some script in our html page the page do not response until the script finishes. By using Web Workers ...

How to show ads in your website using Google ad sense

Hello readers , Following are the steps to guide how you can show ads in your site. Step 1 First sign in with google ad sense account using below link https://www.google.com/adsense/start/ Step 2 After sign in with your googl...

How to get the last url using Javascript

Hello Reader's! If you are stuck in a condition where you need to redirect old url. Then the quickest way to get previous url is by Javascript. By using the document.referrer function. Let's see the example below:- <script> var oldU...

How to change page background on the day time basis using Javascript

Hello Reader's! If you want to change your web background image automatic on the day time basis, i.e. for day it will show pic 1 and in night it will show pic 2 as background. Lets see the full example below:- </bo...

how to remove duplicate key values from an array using Javascript

Hello Reader's, If you have an array having the multiple duplicate key values then by using Javascript you can make them skip. Let's see the example below:- Lets say an array full of duplicate data. var axes2=[1,4,5,2,3,1,2,3,4,5,1,...

How show image on click event using Javascript

Hello Reader's If you want to show image on a click event. Then using javascript you can use this in real time. Let's see the example below:- <button onclick="add_google_logo();">Add Google Logo</button> Now the JS will go li...

How to print current date in html div using Javascript

Hello Reader's If you want to show current date in a html div, Then you can genrate it in JS then show back to html. Here is the example below:- <div id="Console"></div> Now the script will go like this:- window.onload = fu...

How to highlight a div using Javascript

Hello Reader's! If you want to make a html page that based on user activity, As user clicks on div then JS will make that div highlight. Let's say our div is - <div tabindex="0">Hello World</div> Here div with tabindex of...

How to replace multiple strings with another multiple strings

Hello Reader's! If you want to replace multiple sting with another multiple stings, then you use the JS function as below:- Lets say a given sentence having strings. var str = "I have a cat, a dog, and a goat."; //sentence to process var ...

How to apply autocomplete feature to textbox with jQuery?

Sometimes we need to implement autocomplete feature to input field for searching purpose. We can do this by using "autocomplete()" with jQuery. Example: In the below example I have created an array of country names and passed that as source to...

How to get smallest key from an array using JS

Hello Reader's! if you have to get the smallest number from the array, Then you can use the JS for short calculation. And here is the example:- Lets say the array is [0] = 54.25 [1] = 536.2 [2] = 100.2 Now make a function and use th...

How to make mobile browser display either in portrait or landscape?

Hello Reader's If you want to make simple Javascript code to make mobile browser display either in portrait or landscape.. This will help you to make your required sreen <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "htt...

How to download an image automatically using Javascript

Hello Reader's! If you want to make your file download by execution of JS then you can use the code below:- var a = document.createElement('a'); a.href = "/favicon.png"; //make the link of image a.download = "favicon.png"; document.body.ap...

How to show selected words in alert box using Javascript

Hello Reader's! If you want to show what the text user has selected in a alert box, Then by using Javascript you can perform this task very quickly. Step1:- <div>Some test text for you to select</div> Make a div that show...

How to make alert message on select the radio button using Javscript

Hello Reader's! If you want to make an alert message for everytime user select the button then you can use the following JS as below:- Lets say our HTML is like this:- <input class="gender" type="radio" name="sex" value="male">Male &...

Ser error message fadeoff on hover of field after submit form.

Hi All Developers, http://www.katjaboehm.de/kontakt/ On this page, after submitting the form. I've setup error message gets fade off (hide) on hover of text field. This form is created using contact form 7. I need same functionality on this...

Check for blank spaces in a sentence without using regex.

For this , we can use jQuery function named as split().Using split() function we can check easily that whether a input string have spaces or not. split function accepts first parameter a delimiter , second parameter is a string and split fun...

How to implement validation for empty input field with jQuery?

Whenever we create a form, we always have a requirement to put validation for empty fields on some input fields. We usually implement this functionality by putting checks on "blur" and onFocus events of the input field. Example: In the below e...

difference between call and apply in javascript?

call() and apply() are two predefined javascript methods. We use both of them to invoke a function & these method must have its own object as a first parameter. apply allow us to invoke the function with passing the arguments in the form...

How to implemente confirm password functionality with jQuery?

At the time of registration or change password we need to provide password, so for this we usually implement Confirm password functionality. Example: In the below example I want to confirm password on form submit, so for this I have created a ...

How to retain the sorted value after refresh div?

Here, we are using both sessionStorage and localStorage to retain the values after refresh a div. The div named refresh (#refresh) get refresh after a time interval of 5s. Values in the array sort using updateContent(arr,$opts) function. These so...

Closures in javascript?

Whenever we defined a function within another function, the inner function has accessibility for the variables in the outer function. Following is the example of closure. function mainFunction(outerData) { var mainFuncData = 3; ...

Include a JavaScript file in another JavaScript file using jquery?

We can achieve this using javascript or using jquery.Below methods demonstrate it. Method 1: Use any JavaScript to include another js file. Step 1: Add following function in your page. function includeScript(url) { var head = ...

How to select option of drop down with Jquery?

Sometimes we need select option of a drop-down dynamically by clicking on a button or on some other action. We can do this by using "selected" property. Example- In the below example I have a drop-down for distance and I want to select option ...

Draggable and resizable a block using HTML5 and Javascript

If you want your block draggable and resizable, the following code will help you for the same: HTML: <section class="map"> <div class="container-fluid"> <div class="this-week panel-group dayListing" id="ac...

Cordova EmailComposer Plugin

The Cordova EmailComposer plugin provides the interface where user can send the message through email same as in the email composer. It manages the editing and sending the message. You can use this plugin to show the standard email view inside yo...

How to implement push notifications in phonegap application.

Using Google Cloud Messaging (GCM) we can send push notification from web server to the android devices that are registered. This is how the process works: 1.Android device sends sender id to GCM server for registration. 2.GCM Server return...

How to show div after some time period with jQuery?

Sometimes we need to display some alert or dive after some period on Web page. We can do this by using setTimeout method as below: <html> <head> <title>Demo to show div</title> <script type="...

How to hide a message after some time interval with jQuery?

Whenever we submit a form or do some task, we usually display a success message, but sometimes it is required to hide this message automatically after some time period. We can do this by two ways: By using setTimeout method: ...

How to retain the selected value in the dropdown after page refresh ?

To retain the selected value in the dropdown on refresh, sessionStorage is used to store the value within the user's browser. First, the values have to be set using sessionStorage.setItem("SelItem", selVal); SelItem is a variable in which we are ...

Drag and drop using Javascript

If you want to drag your element from one point to another, here is the code below using Javascript: HTML: <div id="dragElement">Drag me!</div> CSS: #dragElement { width:100px; height:100px; background-color:#66...

Javascript popup boxes

Hello Readers Javascript has three kind of popup boxes: Alert box Confirm box. Prompt box. Alert box: If you want the information comes through the user then we use the alert popup box. Syntax of alert box: window.alert("som...

Compare two numbers

Can you tell me why this isn't working with comparing numbers?? All assistance is truly & greatly appreciated. function init(){ var a = document.getElementById("a").value; var b = document.getElementById("b").value; var com...

What is the use of % in javascript

using the '%' will make the modular opera, Function of % is return the remainder of the two numbers:- Lets see the example below:- <script> var x = 100; //var 1 var y = 30; //var2 var z = x % y; // z will be the remainder a...

How to convert a integer to binary using Javascript

Hello, If you need to convert the interger to binary then by using Javasript you can perform it very fast, Let see the example below:- var binary = (56 >>> 0).toString(2); console.log(binary); console.log(parseInt(binary, 2) >&...

how to identify location is enable or not on browser with jQuery?

To get the user's current location use the getCurrentPosition() method. This method contains two parameters, first parameter is success for providing locationd and second one is error to handle errors for ex: getCurrentPosition(success,error) ...

How to Disable Submit Button Until all Fields have Values?

To make the submit button disable until all the fields have some values, we will be using keyup() function that provide handler to check not null values. We disabled the register button in the starting and according to the value from handler, ...

.keyup() method in jquery

.keyup() method is used to bind an event handler with the keyup javascript event. Suppose we have an input field and we want to invoke an alert box for each key we press. Then, the event handler should be bind to that input field. Example: ...

How to get browser current timezone with jQuery?

Sometimes we need to identify the clients timezone to make some calculation on time. For example - we want to save current time based on user's timezone into database, so in this case we need to get the user's current timezone. To do this down...

How to detect if enter key is pressed with jQuery or not?

Sometimes we need to detect where ENTER key is pressed or not to do some action. The "enter" key is represent by code 13 (ASCII value). To detect whether ENTER key is pressed on Web-page or inside an input field, we can bind keypress() eve...

How to put validation on a file at the the time of selection in Jquery?

Sometimes we need to apply validations on file-size and file-type of a file while uploading. We can check this by attaching a function to the "change" event. Examlpe: <input type="file" name="uploadFile" id="uploadFile" class="upload" t...

How to make time slice using Javascript

Hello Reader's If you are genrating the time in Unix time stamp and want to show it like 5 min ago or 3 hours ago then you can use the code below:- Here we are using NOW of the unix timestamp function timeSince(ts){ now = new Date(); ...

How to make the navbar tab active on click?

To make the clicked tab active in the navigation bar, the <li> corresponding to the clicked href in index.html introduces the css of 'active' class and removes the 'active' class from the previous <li> on click. Example: index....

Escaping string in Javascript

The escape function returns a hexadecimal encoding of an argument in the ISO Latin-1 character set that contains the contents of charstring. The Syntax is: escape("string") String is a string in the ISO Latin-1 character set. The value...

Converting a value to Integer

When the user types a value in an edit box or selects a value from a text-based control, the value is considered a simple group of words and the browser may not be able to identify or categorize what exists in a text-based control. The parsetInt(...

How to use PHP inside the Javascript

Hello Reader's!. If you having the JS file and you need to do some php coding inside the file, Then you can use the following coding standard:- <script type="text/javascript"> var jsVvariable = <?php echo json_encode($phpVariable); ?...

How to return multiple variables using Javascript

Hello Reader's!, If you have a condition in which you need to return two or more variable from function like below:- functions() { //you calculation for result return $a, $b; } Now you will face the error. But you can use the arr...

How to pass xml data in Jquery

Hello Reader's!, If you have given a xml data and you need to parse it into Jquery, Then you can use the parseXML function. Let's see the example below:- var xml='<Pages><Page Name="test"><controls><test>parsing into ...
1 9 13
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: