Last active
July 27, 2016 07:18
-
-
Save charleslouis/7436283 to your computer and use it in GitHub Desktop.
#value #placeholder #attribute #html5 #form #input #inputfiled #jquery
This file contains hidden or 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
| function valueToPlaceHolder(divId){ | |
| // this function creates a placeholder based on the attribute 'value' of this same input text field | |
| //once done, it removes the 'value' attribute | |
| // it is useful for cforms II plugin cos placholder are not available, while default value attr are | |
| // THIS : | |
| // <input xxx value="Prénom - First name" xxx> | |
| // would return : | |
| // <input xxx placeholder="Prénom - First name" xxx> | |
| // see http://stackoverflow.com/questions/11432144/change-value-to-placeholder-input-field | |
| if( document.getElementById(divId) ){ | |
| $('input[type="text"]').each(function() { | |
| var $this = $(this); | |
| $this.attr('placeholder', $this.attr('value')).removeAttr('value'); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment