7 jQuery Code Snippets every web developer must have

By | September 3, 2013
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInDigg thisPin on Pinterest

jQuery extensively simplified web developer’s life and has become a leader in JavaScript available libraries. There are a lot of useful jQuery snippets available but here in this post I am going to share 7 basic and widely used code snippets that every front-end web developer must have. Even for those who are new to jQuery can easily understand and get benefit from these routinely used code snippets.

1. Print Page Option

Providing option to print a page is a common task for web developers. Following is the available code:

Let’s Take a simple Online Free Test on jQuery. Click here.

2. Helping Input Field/Swap Input Field

In order to make an Input Text field helpful, we normally display some default text inside it (For Example “Company Name”) and when user click on it, text disappears and user can enter the value for it.
You can try it yourself by using the following code snippet:

3. Select/Deselect All options

Selecting or Deselecting all available checkbox options using a link on HTML page is common task.

4. Disabling Right Click

For web developers, its common to disable right click on certain pages so following code will do the job.

5. Identify which key is pressed.

Sometimes, we need to validate the input value on a textbox. For example, for “First Name” we might need to avoid numeric values. So, we need to identify which key is pressed and then perform the action accordingly.

6. Validating an email.

Validating an email address is very common task on HTML form.

7. Limiting MaxLength for TextArea

Lastly, it usual to put a textarea on a form and validate maximum number of characters on it.

This is my selection of jQuery code snippets but jQuery is a very powerful client-side framework and a lot more can be done using it.


Other Related Articles:

Top 10 Interview Questions and Answers Series:

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInDigg thisPin on Pinterest
Category: Javascript jQuery Tags: ,

About Web Development

Imran Abdul Ghani is working as Software Developer(Senior) with extensive knowledge in Web development technologies especially C#, ASP.NET, MVC, WCF, Web API, ADO.NET Entity Framework, jQuery etc. He has several years of experience in designing/developing enterprise level applications. He is Microsoft Certified Solution Developer for .NET (MCSD.NET) since 2005. You can reach his blogging at www.webdevelopmenthelp.net, www.topwcftutorials.net, and www.sharepointfordummies.net.