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

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

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

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

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

Circular graphs in SVG

Hello, Here I am sharing some information related to circular graphs using Javascript. JavaScript provides a library that generates circular graphs in SVG. We need to include circles.js or circles.min.js file in the HTML file. It can be do...

How to validate file extension and size before upload?

Here is the example to validate the file extension and size before upload. Regular expression has been used to validate the file extension. And to validate file size, we use size property of file input i.e., img.files[0].size. Onclick event of bu...

How to detect if user click inside and outside of an Iframe

Hello Reader's! If you are developing the contents with Iframe window and you want make it show the click inside and outside the iframe, Then you can use the code below:- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> &...

How to show loading icon while page is loading

Hello Reader's, If your webpage is taking too long to take data from database and you want to fix a loading icon for the time then you can use the following Javascript based code for that:- First Step:- Write the following code just after yo...

How to convert Javascript object into array

Let's see the example below:- We have a numb as JS object var numb = { 1: [22, 33, 44], 2: [11, 99, 66] }; var DefineArray = $.map(numb, function(value, index) { return [value]; }); console.log(DefineArray); Ou...

How to load header and footer using Javascript

Hello Reader's. If you have developed the header and footer of the website separatly then it's very easy to make them render on a webpage. By using the JS you can call them with a single line of code as written below:- <html> <head&g...

How to detect the arrow key on press using Javascript

Hello reader's! If you are making the website based on user press key events. Then to detect the arrow key pressed by user we can code as below:- document.onkeydown = function(e) { switch (e.keyCode) { case 37: alert...

What is mean by +_ in JS

Hello Reader's Sometimes you might have seen " var = +_" syntax in JS. So this line is as simple as assiging the variable to another, Where + is transfering the value of _ to var and _ is just the variable. var _ = "D5200"; var newVar = +_;...

How to get the POST variable using Javascript

Hello Reader's! If you have desinged the html form in PHP and want to receive the POST variables in JS then there is a method below:- var PostVar = <?php echo $_POST['name'] ?>; Like the way above the var PostVar will get the val...

How to get the variable by it's name using Javascript

Hello Reader's, Suppose you having a variable and you want to find it by it's name, See the example below:- var MyVar = '12'; alert(window['MyVar']); Output:- 12 No if you have variable like this way var MyVar = {IND:'value12...

How to detect if web page is refreshed using Javascript

Hello Reader's! if you need to detect whether the webpage is being refreshed by using Javascript you can do this like the example below:- function CheckRefresh() { if(document.cookie.indexOf('mycookie')==-1) { // cookie doesn't exist, ...

how to convert string into date format using Javascript

If you have a sting in the format of dd-mm-yyyy and you need to convert it into date format then you can see the operation below:- var date1 = "07-11-2015"; var numbers = date1.match(/\d+/g); var date = new Date(numbers[2], numbers[0]-1, n...

How to make custom HTML 5 email validation

Hello Reader! If you have been working with HTML 5 validation then on incorrect email address web broser will show the default error message "please enter a valid email address". Now you can make it custom and write your own message. Lets see t...
1 7 9 10
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: