My favourite jQuery expressions


This is purely for me and to remind myself of the frequently used jQuery expressions. Forgetfulness is a curse as well as a bliss!

[sourcecode language="javascript"]
$("#target option:first").attr('selected','selected');
[/sourcecode]

[sourcecode language="javascript"]
function(result) {
var options = '';
for(var i=0; i<result.length; i++) {
options += '<option value="' + result[i].Id + '">' + result[i].Name + '</option>';
}
$('#<%= Html.ClientIdFor(m => m.Input.ProductCategoryId) %>').find('option').remove().end().html(options);
$('#<%= Html.ClientIdFor(m => m.Input.ProductCategoryId) %> option:first').attr('selected', 'selected');
}
[/sourcecode]

[sourcecode language="javascript"]
$('#result').delegate('a[name="lnkDescription"]', 'click', function(e) {
e.preventDefault();

var link = $(this).closest('tr').find('a[name="lnkDescription"]');

...
});

})
[/sourcecode]