Compare Page Revisions
« Older Revision - Back to Page History - Newer Revision »
Table of Contents [Hide/Show]
Online Repositories jQuery jQuery UI Field Values Text, Hidden, and Password Fields DropDownList CheckBox Radio Button Page Element Properties Enable/Disable Visiblility Selectors General Children Attributes Form Selectors Special Selectors AJAX Calls Client Code, AJAX Client Code, JSON Server Code Common Functions
$(selector).val()
$(selector).val('newValue')
$('select#id option:selected').val()
$('select#id option:selected').html()
$(selector).is(':checked')
$(selector).attr('checked', 'checked')
$(selector).removeAttr('checked')
$('input:checked[name=MyName]).val()
$('input[name=MyName]').filter('[value=MyValue]').attr('checked', 'checked');
$('input[name=MyName]').removeAttr('checked');
var enabled = !$(selector).attr('disabled');
$(selector).removeAttr('disabled')
$(selector).attr('disabled','disabled')
$(selector).is(":visible")
$(selector).show()
$(selector).hide()
$('div')
div
$('#myId')
id='myId'
$('.MyClass')
MyClass
$('selectorE + selectorF')
selectorF
selectorE
$(selectorE).next('selectorF')
$('selectorE ~ selectorF')
$('selectorE, selectorF')
$(':not(selectorE)')
$(':empty')
$('selectorE selectorF')
$('selectorE > selectorF')
$('li:nth-child(2)')
li
$('tr:nth-child(odd)')
tr
$('.myclass:nth-child(3n+2)')
myclass
$('li:first-child')
$('li:nth-child(1)')
$('li:last-child')
$('li:only-child')
$('[rel]')
rel
$('[rel=value]')
value
$('[rel!=value]')
$('[rel^=value]')
$('[rel$=value]')
$('[rel*=value]')
$('[rel~=value]')
$('[rel|=value]')
$(':input')
input
select
textarea
button
$(':text')
<input type='text'/>
$(':password')
<input type='password'/>
$(':radio')
<input type='radio'/>
$(':checkbox')
<input type='checkbox'/>
$(':submit')
<input type='submit'/>
$(':image')
<input type='image'/>
$(':reset')
<input type='reset'/>
$(':button')
<input type='button'/>
$(':file')
<input type='file'/>
$(':enabled')
disabled
$(':disabled')
$(':checked')
$(':selected')
option
$(':eq(N)')
$(':gt(N)')
$(':lt(N)')
$(':first')
$(':last')
$(':even')
$(':odd')
$(':parent')
$(':contains(value)')
$(':has(selectorE)')
$(':visible')
$(':hidden')
$(':header')
<h1>
<h2>
$(':animated')
$.ajax({ type: "{ GET | POST }", url: "/Controller/Method", async: { false | true }, datatype: 'json', data: { param1: value1, param2: value2 }, success: function(data) { $.each(data, function(key, val) { // do something with each value }); /* each */ }, /* success */ error: function(xhr, ajaxOptions, statusDescription) { alert(statusDescription); } /* error */ }); /* ajax */
async
data
url
success
type
error
datatype
Response.StatusCode
500
statusDescription
Response.StatusDescription
[HttpPost] public JsonResult MyMethod(MyModel m) { if (!ModelState.IsValid) { var response = (from ms in ModelState.Values from err in ms.Errors select err.ErrorMessage).ToList().FirstOrDefault(); Response.StatusCode = 500; Response.StatusDescription = response; //return Json(response); return null; } m.SaveToDatabase() return Json(""); }
$.getJSON( url, { param1: value1, param2: value2 }, // optional function (data) { } ) // optional success method .success(function(){ }) // optional error handler .error(function(){ });
[HttpGet, Authorize] public JsonResult GetData(int regionID) { IQueryable items = MyDataProvider.GetData(regionID); return Json(items, JsonRequestBehavior.AllowGet); }
$(selector).append(content)
.append(content)
.children(selector)
.closest(selector)
'form'
.eq(index)
.filter(selector)
.find(selector)
.first()
.hasClass(class)
.html()
.last()
.next(selector)
.parent(selector)
.prepend(content)
.prev(selector)
.replaceWith(content)
.toggle()
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.