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.
Category » jQuery
Difference between Attr and Prop in jQuery
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.
Disable or enable an input field with jQuery
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.
4 ways to empty an array in JavaScript
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
Prevent binding of events multiple times in jQuery
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.
Check or Select / Deselect all Checkboxes using jQuery
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).
event.preventDefault() vs. return false
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
Getting query string values in javascript
Sometimes we get the important data through query string but question is of getting query string values in javascript or jquery because we need these values at client side. Even we can do it by using only javascript also.
Return the response from AJAX call – the right way to do
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.
Validate email address in jQuery or JavaScript
Form validation is essential part of programming. We can validate email address in jQuery or JavaScript using regular expression. In this article, both are explained. You can check the live demo as well.