$(key).val().length jquery code example Example: jquery count elements var count_elements = $('.class').length;