Fayakon
Fayakon

Reputation: 1523

How to change TextArea placeholder text using javascript

i am trying to change pleaceholder text when document loads, i tried following code but it's not working,

HTML:

    <textarea id="nf-field-195" name="nf-field-195" class="ninja-forms-field nf-element" 
placeholder="Please provide a brief description of your facility" required=""></textarea>

JS:

<script>
jQuery(document).ready(function( $ ){

 $('#nf-field-195').attr('placeholder','Some New Text 1');
});
</script>

JSFiddle

Upvotes: 0

Views: 44

Answers (1)

Bernhard Beatus
Bernhard Beatus

Reputation: 1216

This should work:

selectedTextarea = $('#nf-field-195')[0];
selectedTextarea.placeholder = "Placeholder text";

Upvotes: 1

Related Questions