You can use parents() from this to find all parents (with a special selector); for the length you have to add one for the current.

alert($(this).parents('.child_set').length + 1);


Also see this example.

How to find element count from child to parent with jquery?
In Drupal 7, you can put the following code in template.php to add the class 'vr-paragraphs' to the field called 'field_title'

function THEMENAME_form_alter(&amp;$form, &amp;$form_state, $form_id) {
       $form['field_title']['#attributes']['class'][] = 'vr-paragraphs';
}


How can I modify this code to target all fields on the form and not just 'field_title'.

Also, this code only adds the class to the form-wrapper part of the filed. How can I alter the label part?

Thanks for any help!
