Change placeholder of an <ons-input> with Javascript



  • I am trying to change the placeholder text of an <ons-input> element by javascript but the placeholder is not updated. I am using:

    document.getElementById('myinput').placeholder = 'newText'
    

    What’s wrong; Please not that the above code works when I turned the <ons-input> to a simple HTML <input> element. So it seems that <ons-input> ignores dynamically changed attributes.

    Thanks!


  • Onsen UI

    @spalamas Try document.getElementById('myinput').setAttribute('placeholder', 'newText'). Perhaps we should make getter/setter for this…


Log in to reply