How to remove options from select using jQuery

We  can sort an array using this method:

  1. This is the select (HTML):
    <select name="selectBox" id="selectBox">
        <option value="option1">option1</option>
        <option value="option2">option2</option>
        <option value="option3">option3</option>
        <option value="option4">option4</option>	
  2. How to remove the items. Just do:
    //Deleting all the items with value equals to 'X':
    $("#selectBox option[value='X']").each(function() {
    $("#selectBox option[value='X']").remove();

Reference link:

How to sort an array of objects with javascript

We  can sort an array using this method:

  1. This is the method to sort the array:
    var array = [(name, artist),(name, artist),(name, artist)];
    function SortByName(a, b){
      var aName =;
      var bName =; 
      return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
  2. How to sort the array with data? Just do:
    var arr = [{name:'bob', artist:'rudy'},{name:'johhny', artist:'drusko'},{name:'tiff', artist:'needell'},{name:'top', artist:'gear'}];

Reference link:

jQuery form autofill

Simply autofill an empty form using JSON data:

  1. We need a form:
    <form id="f">
        name <input type="text" name="name">
        email <input type="text" name="email">
        love jQuery
        <input type="radio" name="lovejquery" value="yes"> yes
        <input type="radio" name="lovejquery" value="no"> no
  2. and data:
    var data = {
        "name": "John Doe",
        "email": "",
        "lovejquery": "yes"
  3. How to autofill the form with data? Just do:
    $("#f").autofill( data );

Reference link:

How to convert an HTML Table into a JSON Object


A jQuery plugin that converts an HTML Table into a javascript object. Great for working with user-editable tables or accessing output from 3rd party tools.:

  1. JavaScript files needed:

    Insert these scripts into <head> tag:

       //download this js from ""
       <script src="js/jquery-1.9.1.min.js"></script>
       //download this js from ""
       <script src="js/jquery.tabletojson.min.js"></script>
  2. Basic Usage JavaScript code:

       //Insert this script into <head> tag:
          //Basic Usage
          var table = $('#example-table').tableToJSON();
  3. Advance Usage JavaScript code:
       //Insert this script into <head> tag
          //Ignore first column (name)
          var table = $('#example-table').tableToJSON({
            ignoreColumns: [0]
  4. Example:
    First Name Last Name Points
    Jill Smith 50
    Eve Jackson 94
    John Doe 80
    Adam Johnson 67
    <table id='example-table'>
          <th>First Name</th>
          <th>Last Name</th>
          <th data-override="Score">Points</th></tr>
          <td data-override="disqualified">50</td></tr>
  5. Result of the example:

    <script type="text/javascript">
      // Basic Usage
      var table = $('#example-table').tableToJSON();
      // table == [{"First Name"=>"Jill", "Last Name"=>"Smith", "Score"=>"disqualified"},
      //           {"First Name"=>"Eve", "Last Name"=>"Jackson", "Score"=>"94"},
      //           {"First Name"=>"John", "Last Name"=>"Doe", "Score"=>"80"},
      //           {"First Name"=>"Adam", "Last Name"=>"Johnson", "Score"=>"67"}]
      // Ignore first column (name)
      var table = $('#example-table').tableToJSON({
            ignoreColumns: [0]
      // table == [{"Last Name"=>"Smith", "Score"=>"disqualified"},
      //           {"Last Name"=>"Jackson", "Score"=>"94"},
      //           {"Last Name"=>"Doe", "Score"=>"80"},
      //           {"Last Name"=>"Johnson", "Score"=>"67"}]

Reference link:

JavaScript libraries comparison

JavaScript Libraries

JQuery Mootols Minified Zepto

Size Comparison

Name Legacy IE Support Compiled Size Compiled and GZip’d
minified-web.js yes 9.1kb 4089 bytes
minified-web.noie.js no 7.7kb 3429 bytes
jQuery 1.10.2 yes 91kb 32kb
jQuery 2.0.3 no 82kb 29kb
MooTools Core NoCompat 1.4.5 yes 88kb 29kb
Zepto.js 1.0 no 27kb 9.7kb

Feature Comparison

Feature Minified jQuery MooTools Zepto.js
CSS Selector yes

CSS1 or browser engine

CSS3 subset + extensions

CSS3 subset + extensions

browser engine
CSS Style Changes yes yes yes yes
CSS Class Changes yes yes yes yes
Element Creation yes yes

HTML-strings only
yes yes

HTML-strings only
Element Cloning yes yes yes yes
DOM Manipulation yes yes yes yes
Animation (numeric) yes yes yes yes

CSS transitions only
Animation (color) yes no yes yes

CSS transitions only
Events yes yes yes yes
DOMReady yes yes yes yes
Ajax/XHR yes yes yes yes
Promises/A+-compatible yes yes no no
JSON yes yes yes yes
Cookies yes no yes no
Form Serialization no yes no yes
Array Helpers (Iteration) no

will be in Util module
yes yes yes
AMD support yes yes no no
Online Builder yes

modules and functions
no yes

Internet Explorer 6-8 compatible yes

IE-support optional

jQuery 1.x only
yes no


Reference link: