Featured
-
Top 10 Template Engines for JavaScript
What is a Template engine? Template Engines are
by nishant.mishra -
jQuery Accordion
Hello readers! In this Blog we will gain knowled
by vishwanath.rana -
How to make Numbered and bulleted list in HTML Editor with JavaScript
Hello all, Working with HTML Editor we wanted t
by gaurav.gautam -
How to hide particular div with just one click?
Hi, you want a condition in which the particula
by abhishek.tiwari.458 -
How to Create and Retrieve Array in Javascript?
If you want to store multiple values in a single v
by siddharth.shahi
Tags
How to get user's browser information using JS
Hello Reader's if you need to keep details of user who visits your website. Then you must know about their web browser. By using Javascript you can easily get this information.
Lets see how to get this informations:-
<!DOCTYPE html>
&l...
How to get user screen's height and width using Javascript
Hello Reader's if you are making the user screen compatible website then you must get the screen hight and width of user.
By using Javascript you can easily get it.
Lets see how to get screen size.
<!DOCTYPE html>
<html>
<b...
How to make range validation of textbox using Javascript
Hello Reader's if you are making the validation of text box to set it's max and min range, Then by using javascript you can do it faster.
Lets see the example as below:-
<!DOCTYPE html>
<html>
<body>
<p>Enter a ...
How to get retrun types of variables in JS
Hello Reader's if you want to get the return types of the variables in Javascript then in this blog you will learn about them.
for getting the return type you have to use the type of function in the JavaScript.
Let's see some of the return ty...
while and do while loops in Javascript
Hello Readers if you are confusing in while and do while loop in Javascript then this blog will be helpfull to you.
Lets see both of them working:-
First we will how while loop works:-
while (i < 10) {
text += "The number is " + ...
All date formats in Javascripts
Hello Reader's If your website getting the dates in different different date formats. Then you can see all the date formats that are valid in JS.
Let's see the below date formats in JS.
var d = new Date("2015-03-25");
var d = new Date("2015-...
Shortest way to find the max element of a array
Hello Reader's if you want to get the shortest way to get the max value of the given array, Then by using JS you do it fast.
To find the result you have to use Math.max() function.
Lets's see the working example as given below:-
<!DOCTY...
How to make calculation in Javascript
Hello Reader's If you want to make the mathematic calculations inside the html document, Then by using the JS you can make calculations.
You just have to use the document.write() function.
Lets see it working in the example as below:-
...
How to change the data inside the div dynamicaly via Javascript
Hello Reader's if you are developing the website that convert the real time data into the div, Then by using Javascript you can do it.
Let's see the example as below:-
<!DOCTYPE html>
<html>
<head>
<script>
functio...
How to show current timestamp by single click on page using Javascript
Hello Reader's if you want to show the current timestamp on the web page by just a single click, Then by using JS you can do it.
Lets see the example below:-
<!DOCTYPE html>
<html>
<body>
<h1>My First JavaScript...
valueOf() method of JavaScript Array
JavaScript Array valueOf() method : The valueOf() method returns the copy of itself. This is the default method of an array object.
Syntax of Array valueOf() method :
array.valueOf()
Example of Array valueOf() method : In this exampl...
unshift() method of the JavaScript Array
JavaScript Array unshift() method : The unshift() method is used to add new item at the first position of an array. The unshift() method will return the new length of an array. The unshift() method will change the length of the array.
Synt...
slice() method of the JavaScript Array
JavaScript Array slice() method : The slice() method is used to get the elements between two position. The slice() method returns the array of extracted elements. It doesn't change the original array. The index starts from 0.
Syntax of the...
Declaring Objects in javascript
Objects are another powerful way of handling and storing of data. In arrays the indexes are commonly numerical; objects give us a better way of assigning and retrieving data.
<html>
<script type="text/javascript">...
Arrays and Objects in Javascript
variables are good and sufficient to hold the single values, But what if we want to store multiple values in a single variable in that case you have to use arrays or objects
Values in arrays are saved index base. Remember that arrays i...
return false vs event.preventdefault
Return false will perform three task when called
1 event.preventDefault();
2 event.stopPropagation();
3 Stops callback execution and returns immediately when called.
The preventDefault() method cancels the event if it is cancellable, ...
What is contents() method in jquery?
Hello Readers,
.contents() method is the jquery method which is used to get the child or children of each element in the set of matched elements including text and comment nodes and its return value is the new jquery objects.
.contents() me...
What is .andSelf() method in jquery ?
Hello Readers,
.andSelf() is the jquery method and it is the alias of .addBack() method because it is deprecated in jquery version 1.8. So, it's replacement is .addBack() method. .addSelf() method is used to add the previous selection to the c...
How to count the number of words in any text?
We can count the number of words by using split method of javascript.
What split method does:
split() - Splits a string into an array of substrings
Below is an example:-
<form name=countingWords>
<textarea rows="12" name...
How to find count and last element of array using Javascript
Hello Reader's If you are working on Javascript and want to get the count of array then you can use the syntax as below:-
var car = ["mode1", "model2", "model4", "model5"];
car.length;
output:
4
And if you want to get last elemen...
How to print dates monthly between two given dates
Hello Reader's if you want to make ajax html form that takes two dates from user and print then daily or yearly or monthly then you can my code as below:-
Lets say the html form, the code will go like this.
<div class="form-group clearf...
shift() method of the JavaScript Array
JavaScript Array shift() method : The shift() method is used to remove the first element of the array. The shift() method will return the first element which will be removed. The shift() method will change the length of the array.
Syntax of th...
reverse() method of JavaScript Array
JavaScript Array reverse() method : The reverse() method is used to reverse the order of the array elements.
Syntax of Array reverse() method :
array.reverse()
Example of Array reverse() method : Here in the following example I wi...
AngularJS Factory
Hi All,
In this we will discuss about factories in Angular JS, as Factory and Services plays an important role in Angular jS application as they allows us to put reusable code at a single place that can later on used in many other places like ...
async attribute is javascript
Hi All,
In this blog we will discuss about the async attribute is javascript, which is a boolean type of attribute that's either can be true or false and when ever we use this attribute to any script tag, it simply denotes that the available s...
What is jquery before() method ?
Hello Readers,
jquery before() method is the opposite of jquery after() method and it is used to insert the given content before the specified of each selected content or elements in jquery.
Syntax :
$(selector).before(content,function(...
jQuery clone() Method
The clone() method is used to make clone of the elements that are matching to the selected elements and select the clones.
It basically makes copies of the selected DOM element to some other place in the DOM.
Syntax:
selector.clone()
...
Touch events in javascript
There are following Touch events in javascript:-
touchmove - this event triggers when the touch point is moved by the user across the touch surface.
touchstart - this event gets triggered when the user makes contact with the touch surface...
What is jquery after() method ?
Hello Readers,
jquery after() method is used to insert the given content after the specified each selected content or elements.
Syntax :
$(selector).after(content,function(index))
content : this is required parameter which specifie...
push() method of JavaScript Array
JavaScript Array push() method : The push() method is used to add new element in the array. The push() method add the new element at the end of the array. The push() method returns the new length of the array.
Syntax of Array push() method...
what is jquery apppendTo() method?
Hello Readers,
appendTo() is the jquery method which is used to insert the any HTML elements at the end of the given selector as a parameter into the appendTo() method.
Syntax :
$(content).appendTo(selector)
Parameters :
content...
How to set check-box with a certain value checked in jquery?
To set a checkbox checked with a certain value we use a function prop() with the attribute selector.
$('selector').prop('checked', true);
For example:
<input class="chkbox" name="ex[]" type="checkbox" value="0">0
<input clas...
What is jquery prepend() method?
Hello Redaers,
jquery prepend() is the jquery method which is used to append or add the content or jquery elements at the BEGINING of the each selected or matched elements in jquery.
Syntax :
$(selector).prepend(content,function(index,ht...
pop() method of JavaScript Array
JavaScript Array pop() method: The pop() method is used to remove the last element of the array. The pop() method returns the removed element. The pop() method changes the length of the array by decreasing one.
Syntax of Array pop() method...
How to integrate time zone in jquery calender
Hello Reader's If you are making the html 5 form then you can integrate the user time zone in the date time calender also, Lets see the example below:-
first you have to downoad the JS an CSS file from here
Now you have to create an html pa...
join() method of JavaScript Array
JavaScript Array join() method : The join() method of the array is used to combine all elements of the array and return as a string by separating elements using the given parameter. By default the elements are separated by comma (,), we can pass ...
DOM Element Replacement in jquery
If you want to replace html element with some other element, the jquery replaceWith method can be used.
You can replace some specified DOM element with the other html or DOM element. The replaceWith() method is used in this case.
Syntax:
...
how to show multiple location from database using lat and long in google map?
Hello Reader's ,
Below is the code for showing multiple location .
Just create a HTML file 'index.html' and put the below code inside the body tag.
<script src="http://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascrip...
Retrieving the text contents and reading the selected portion of a field's value
To retrieve the text selected by the user is to get the indices of the starting and the ending character of the selection. After that you need to extract that particular portion from the form fields value using those retrieved values.
To get ...
Slidebar Menu plugin in Jquery
We can create a slidebar menu using jquery slidebar plugin. It is a jQuery plugin that gives a slidebar menu for easily implementing in the web pages.
We have to include slidebars.js in our source files.
Here is an example that shows how to...
Jquery animate() method
Hello Readers,
The jQuery animate() method is used to create custom animations.
If you want to create some animation effect in your HTML, then you can use jQuery .animate() method for the same.
We use following syntax for create animation....
How to check an element is exists or not?
In JQuery to check that element is exists or not we use length() function. Using length() function we will check the length of the selector, if it returns something then the element must exists else not.
if( $('#selector').length ) /...
jQuery detach( ) method
This method is used to remove the selected elements( i.e all text and child nodes as well ). If we want to reinsert that removed elements , we can do that easily because it keeps a copy of the removed elements.
Syntax :
$(selector).detach()...
QueryString Value in Javascript
Hi All,
Here is quick way to get query string value in javascript:
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
...
lastIndexOf() method of JavaScript Array
JavaScript Array lastIndexOf() method : The lastIndexOf() method returns the last index of the given item inside the array. This method is used when array has an element more then once. It returns the numeric value 0 or greater if element found, ...
jQuery Filtering - eq( ) method
This method is used to return the element with choosing index number of the selected elements.In this method, indexing is starting with 0 i.e first element have a index number 0.
Example :
HTML Code :
<!DOCTYPE html>
<html>
...
jQuery Filtering - last( ) method
This method is used to return the last element of the selected elements.This filter help users to filtering the selected elements.
Example :
HTML Code :
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<...
jQuery Filtering - first( ) method
This method is used to return the first element of the selected elements.
Example :
HTML Code :
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div style="border: 1px solid black;">
<p>This...
jQuery toggle( ) Method
This method is used to work with multiple functions i.e when you click on selected element first function will be fired and when you click on that selected element second function will be called and so on.
Syntax :
$(selector).toggle(functio...
How to set values of select box dynamically using Jquery
Hello Reader's if your building the html 5 based web form and want to set the value of select box via Jquery then you can learn it from code as below:-
First you need to set the value from html page
<input type = "text" id = "txtEmail" v...