Skip to content

Instantly share code, notes, and snippets.

@jeffreynolte
Created July 25, 2013 19:26
Show Gist options
  • Save jeffreynolte/6082938 to your computer and use it in GitHub Desktop.
Save jeffreynolte/6082938 to your computer and use it in GitHub Desktop.
Add placeholders to all list elements in Gravity Forms.
$('.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());
});
@CHEWX
Copy link

CHEWX commented Feb 21, 2018

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() );

    });

});

@nickmeagher
Copy link

nickmeagher commented Aug 28, 2019

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);

});

@Tibebu-ES
Copy link

The data-label attribute of gfield_list_cell can be used to remove the additional text in the aria-label attribute.
This works fine for me.

comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment