Geeks With Blogs
Stuff I do my notepad

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:
$('#id').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: ,
Posted on Wednesday, December 16, 2009 8:28 PM jQuery , ASP.NET | Back to top


Comments on this post: My jQuery cheat sheet

# re: My jQuery cheat sheet
Requesting Gravatar...
Thanks for sharing! Good job!
Left by Catherine Russell on Feb 17, 2010 7:33 PM

# re: My jQuery cheat sheet
Requesting Gravatar...
:) You wellcome
Left by Vladimirl on Feb 17, 2010 8:09 PM

Your comment:
 (will show your gravatar)


Copyright © vladimirl | Powered by: GeeksWithBlogs.net | Join free