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

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 &...

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...

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 ...

Refresh the parent window and close the child window on clicking the button in child window

How to refresh the parent window and close the child window on clicking the button in child window using JavaScript If you want to close your child window and refresh its parent window on click of a button, we can do that with the help of foll...

How to subtract days from a given date?

Hello Reader's. If you have given a date and you just need to add or subtract number of days from it then you can use the code below:- var SubDays = 15; $.datepicker.formatDate('yy/mm/dd', new Date() - SubDays) ; Or you can also calculat...

How to convert Json Object into Json Array

Hello Reader's. If you have a json object and you need to convert it into array then you just need to write the code below, and you will get the array converted format. var obj = {"0":"1","1":"2","2":"3","3":"4"}; var arr = []; for (elem ...

How to change HTML tags using Javascript

Hi If you want to change the tags of HTML with another tags then you can perform this action using JS in realitme. Let's consider and example to change the <h2> tag with <i> using JS. <h2 class="xyzxterms" style="cursor: defaul...

What is the best place to load JS in html

Hello Reader's!, If you need to know which is the best place for putting the JS. You can put the js functions in the head part. But it'll be a good habit to put all of your functions in a separate file. You can also call for the external script...

How to detect if caps lock is on/off

Hello Reader's, If want to make alert when the upper/lower case letter key is pressed. Then by using Javascript you can see it in the code below:- $('#cap').keypress(function(e) { var s = String.fromCharCode( e.which ); if ( s.toU...

How to add minutes in a given date using Javascript

Hello Reader's, If you need to add some minutes to a given date, Then by using Javascript you can use as follows:- var d1 = new Date (), d2 = new Date ( d1 ); d2.setMinutes ( d1.getMinutes() + 50 ); //adding 50 min to the date alert ( d...

How to detect a textbox's content has changed

Hello Reader's If want to detect if text box value changed the alert box open to user. Then you can perform this function by using the Javascript. The function is written below:- $(function() { var content = $('#txtbox').val(); $...

How to make a simple file reader using Javascript

Hello Readers, If you developing the website to browse any file and showing its's content on the web page, Then by using Javascript you can do this as follows:- function readSingleFile(e) { var file = e.target.files[0]; if (!file) { ...

HTML5 Canvas Game

Canvas can be used to draw graphs, shapes, images, and to make animations. Here is the example below for making the game in canvas <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> ...

Display image before upload using javascript/jQuery

This post demonstrates how to display an image prior to uploading it on server. This demo uses the JavaScript's readAsDataURL method of reader API which will read image as url. <html> <head> <script src="https://a...

Middleware in Express JS

Middleware is the core idea of Express.js used behind processing the request and routing. By seeing how middleware functions, you can make more maintainble applications with less code. The minute a solicitation is gotten by an Express.js applicat...
1 8 10 11
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: