I want to put in this post some the jQuery methods that I found myself searching the web every other time i need them for the future reference.
Check if element exists:
if ($('#elementID').length > 0)
{
// do somehting
}
Disable/enable element
$('#elementID').attr('disabled', 'disabled');
$('#elementID').removeAttr('disabled');
Clear DropdownList or ListBox
$('#ddl_ID >option').remove();
Add entry in the DropDownList or ListBox
$('#ddl_ID').append($('<option></option>').val(1).html('Text'));
Getting the text and value of the selected item in DropDownList
var selectedValue = $('#ddl_ID').val() or $('#ddl_ID option:selected').val() ;
var selectedText = $('#ddl_ID option:selected').text();
Check/uncheck checkbox:
$('#id]').attr('checked', true);
$('#id').attr('checked', false);
Check if checkbox is checked:
Check if element is disabled
$('#id').is(':disabled');
Check if element is visible/hidden
$('#id').is(':visible')
$('#id').is(':hidden')
There are a lot of resources available. I like stackoverflow.com. Here is a nice topic - jQuery Tips and Tricks (http://stackoverflow.com/questions/182630/jquery-tips-and-tricks)
And there is one more to dig - jQuery HowTo (http://jquery-howto.blogspot.com/)
more to come...
Technorati Tags:
jQuery,
ASP.NET