Created
July 25, 2013 19:26
-
-
Save jeffreynolte/6082938 to your computer and use it in GitHub Desktop.
Add placeholders to all list elements in Gravity Forms.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.gfield_list_cell').each(function(){ | |
var $this = $(this), | |
$tr = $('tr', $this.parent().parent().prev()), | |
i = $this.index(); | |
$('input', $this).attr('placeholder', $('th:eq('+i+')', $tr).text()); | |
}); |
For multiple list support use:
$( '.gfield_list_group' ).each( (i, el) => {
$( el ).find('.gfield_list_cell').each( ( x, element ) => {
let $this = $( element ),
$tr = $('tr', $this.parent().parent().prev());
$('input', $this).attr('placeholder', $('th:eq(' + x + ')', $tr).text() );
});
});
This is what worked for me:
$('.gfield_list_cell').each(function() {
// Set vars
var input = $(this).children();
var label = input.attr('aria-label');
// Set placeholder
input.attr('placeholder', label);
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where do you add this code snippet?