daily pastebin goal
69%
SHARE
TWEET

Move sublabels above inputs (corrected)

chrishajer Mar 21st, 2013 210 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // for: http://www.gravityhelp.com/forums/topic/address-labels-below-fields#post-175408
  2. // copied from here: view-source:http://dev.calgunsfoundation.org/get-help/hotline/
  3. // discussed here: http://stackoverflow.com/q/15490308
  4. // add the script below to an HTML block in your form
  5. // corrected March 21, 2013 to properly handle email fields
  6. // reference http://www.gravityhelp.com/forums/topic/change-position-of-sub-labels-on-advanced-fields?replies=13#post-177133
  7. // props DrDavid
  8. <script type="text/javascript">
  9. jQuery('.ginput_container label').each(function(i,e){
  10.               fielddesc = jQuery('<div>').append(jQuery(e).clone()).remove().html();
  11.               jQuery(e).siblings('.ginput_container input[type=email]').before(fielddesc);
  12.               jQuery(e).siblings('.ginput_container input:text').before(fielddesc); //moves sub label above input fields
  13.               jQuery(e).siblings('.ginput_container select').before(fielddesc); //moves sub label above select fields (e.g. country drop-down)
  14.               jQuery(e).siblings('.ginput_container .gfield_radio input').after(fielddesc); //keep label above radio buttons
  15.               jQuery(e).siblings('.ginput_container .gfield_checkbox input').after(fielddesc);
  16.               jQuery(e).remove();
  17.           });
  18. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top