Council. How to add placeholder to textarea in Ninja Forms Wordpress plugin
This is not really a question. I just felt like I needed to share this little magic with all peeks where there is a tough time to get a placeholder in the Ninja Forms text area field.
So, basically you need to add the following code to your header.php file in the section head
, and then change the id of the textbox and select the placeholder text.
<script type="text/javascript">
jQuery(document).ready(function($){
$('#yourTextareaID').attr("placeholder","Your placeholder value");
});
</script>
Hope this helps save you some time. You can thank me later.
+3
source to share
2 answers
The way to do this, to make it work for any textarea, would be to set (in Ninja forms) the default value of the textarea to be what you want the placeholder to be, and then on page load, grab the content of each textarea. add it to placeholder attribute, then remove the content:
$(document).ready(function() {
// Remove textarea content and add placeholder
$("textarea").each(function() {
var $this = $(this);
$this.attr("placeholder", $this.val());
$this.val("");
});
});
+5
source to share