Kyle
Kyle

Reputation: 1183

How to insert a jQuery string into the placeholder element on an HTML form

This is a branch question from Typewriter Effect with jQuery

http://jsbin.com/araget/5

I'd like to sequentially inject and clear each string from the array into the 'placeholder' element on an html form. The function currently writes and clears each string into an empty span element.

No experience with jQuery :/, any tips on how to go about doing this?

Upvotes: 0

Views: 570

Answers (1)

Use .attr()

$(element).attr('placeholder','Write text here'); 

to get value of placeholder attribute in jQuery

var placeholder_value = $(element).attr('placeholder'); 

Better use .prop()

$(element).prop('placeholder','Write text here'); 

to get value of placeholder attribute in jQuery

var placeholder_value = $(element).prop('placeholder'); 

Commented by Tats_innit

Read

Upvotes: 3

Related Questions