JQuery Cheat Sheet

  • Disable an input control*:
    $("input").prop('disabled', true);
    $("input").prop('disabled', false);
  • Set an image*:
    $("#my_image").attr("src","second.jpg");
  •  Classes:
    • Add a class*:
      $("p").addClass("myClass yourClass");
    • Remove a class*:
      $('p').removeClass('myClass yourClass')
    • Select all of a class, except one *:
      $(".thisclass:not(#thisid)").doAction();
  • Selected Text*:
    $("#title").val();
    $("#title option:selected).text();
  • Set values in an array to zero *:
    $.each(arr, function(i, e) {
      arr[i] = 0;
    });
  • Select / Dropdown Box

Leave a Reply

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