substring() is one of the main string function which is mostly used in javascript. The substring() method extracts the characters from a string, between two specified indices, and returns the new sub string.

Read More

Many developers confused with the Attr and Prop keyword in jQuery. So We are describing here the difference between Attr and Prop in jQuery. The segregation of attr() and prop() should help alleviate some of the confusion between HTML attributes and DOM properties.

Read More

For jQuery 1.6 or above there is prop() function and lower jQuery versions have attr() function which can be used to disable or enable an input field. Further more DOM object’s disabled property also works with any version of jQuery to disable or enable an input field.

Read More

JavaScript arrays are commonly used by developers and making them empty is also used in practice. Here I am describing 4 ways to empty an array in JavaScript:

1. Use splice() method
2. Set length to zero
3. Using pop() method
4. Set array to new empty array

Read More

Either newbie or experienced developer, everyone occasionally stuck with a situation that it’s  event binding runs in a loop or multiple times and it runs unexpected and we are unable to find the bug because we bind the event only one time but in practical it binds so multiple times.

Read More

Either newbie or experienced developer, everyone occasionally needs a quick jQuery snippet that selects and deselects multiple checkboxes by clicking “Select All” checkbox (exactly like in Gmail). Here are two code snippet that perform the same action. You can use either of them.

We are creating two functions (in each code snippet).

Read More

event.preventDefault() vs. return false is a very important but confusing topic that which one should be used and for what. When we want to prevent other event handlers from executing after a certain event is fired, we can use one of these two techniques

Read More

AJAX is common now a days. People try to implement AJAX but fail to return the response from AJAX call successfully because they misunderstood the concept behind AJAX and the right way to do that.

Here I have tried to explain the flow and restructure the code for AJAX to let your application work. First I have explained the problem then the meaning of AJAX and flow as well followed by the solution.

Read More

[ Page 6 of 10 ]