简体   繁体   中英

Setting placeholder text jQuery

I have this working code which I'm using to set placeholder values for username and password fields:

<script>document.getElementById("user_login").setAttribute("placeholder","Please enter your Email Address");</script>

and

<script>document.getElementById("user_pass").setAttribute("placeholder","Please enter your Password");</script>


Now I'm trying to apply this to a 3rd box which has the input ID #memb_password_send-1-email-input but this isn't a straight up element, it's an input field and using this ID (as above) obviously doesn't work.

Here is a picture of console:

IMG 01

What would be the correct way to target this field with placeholder text?

Same method used to provide placeholder for username and password fields would work in this case as well as those are input fields as well. Just make sure that when you are writing this code in in-line script, do this after that input box has rendered ie after it's markup so that element is available to get selected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM