jQuery Tips & Tricks Collections

1. Dom Ready Method

2. Create new element

As of jQuery 1.4, we can now pass an object as the second parameter of the jQuery function. This is helpful when we need to insert new elements into the DOM.

3. AJAX Methods

  • load(): Load a piece of html into a container DOM.
  • $.get(): Use this if you want to make a GET call and play extensively with the response.
  • $.post(): Use this if you want to make a POST call and don’t want to load the response to some container DOM.
  • $.getScript(): Load a JavaScript.
  • $.getJSON(): Load a JSON with GET method.
  • $.ajax(): Use this if you need to do something when XHR fails, or you need to specify ajax options (e.g. cache: true) on the fly.

4. Scroll to Top

5. Equal Column Heights

6. Center an element on the Screen

7. Detect browser

8. Clear Form Data

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA