This is a draft cheat sheet. It is a work in progress and is not finished yet.
TextBox
Get Value |
$("#id").val() |
Set Value |
$("#id").val("new value") |
Enable |
$("#id").prop("disabled",false); |
Disable |
$("#id").prop("disabled",true); |
Hide |
$("#id").hide() |
Show |
$("#id").show() |
On Lost Focus |
$("#id").on('change', function) |
On Lost Focus |
$("#id").change(function) |
On Focus |
$("#id").focus(function) |
Set Focus |
$("#id").focus() |
On Change (via keyboard) |
$("#id").on('keyup paste mouseup', function) |
Add Class |
$("#id").addClass("something") |
Remove Class |
$("#id").removeClass("something") |
Get Length |
$("#id").val().length |
Checkbox
Check if checked |
$("#id").is(":checked") |
Check if not checked |
$("#id").is(":not(:checked)") |
Set Checkbox |
$("#id").prop("checked", true) |
Unset Checkbox |
$("#id").prop("checked", false) |
Disable, enable, add class, remove class is the same as textbox
Select Box
Selected (hidden) Value |
$( "#id" ).val(); |
Text of selected option |
$( "#id option:selected" ).text() |
On selecting an option |
$("#id").change(function) |
Select an option using code |
$("#id").val(3); |
Disable a single option |
$("#id option[value='3']").attr("disabled", true); |
Enable a single option |
$("#id option[value='3']").attr("disabled", false); |
Alerts and Ask Value
Alert bootbox.alert("message")
|
Confirm bootbox.confirm("question",function (r) { if (r) dosomething } )
|
Ajax
Get record |
Save record |
Delete record |
|
|
|