0

I have an input with dynamically loaded value. When value appears on input field, placeholder should disappear. Everything works fine but when I turn on VoiceOver placeholder does not disappear and text overlaps it.

Here is an example: https://jsfiddle.net/t8ykvp8e/

<input type="text" placeholder="Placeholder text" value="">

setTimeout( function() {
  $('input').attr('value', '123')
}, 2000)

Do you have any ideas how to fix it? Thanks!

Mmm Yyy
  • 1
  • 1

1 Answers1

0

You should use jQuery's val method to set the input element's value. Using attr only modifies the element's value attribute (in other words, its initial value), which might account for the strange behavior in combination with VoiceOver.

$('input').val('123');

Also see: Properties and Attributes in HTML

Community
  • 1
  • 1
Brother Woodrow
  • 6,092
  • 3
  • 18
  • 20