简体   繁体   中英

Javascript, I am not being able to cursor to input box

I can't set focus on html input, I tried this code, And it doesn't work.

document.getElementById('ember19').focus();
document.getElementById('ember19').click();
document.getElementById('ember19').select();
document.getElementById('ember19').value='Badman55555@hotmail.com';
document.getElementById('ember19').setAttribute('value','Badman55555@hotmail.com');

document.getElementById('ember22').focus();
document.getElementById('ember22').click();
document.getElementById('ember22').select();
document.getElementById('ember22').value='Bad123456';
document.getElementById('ember22').setAttribute('value','Bad123456');

Please before answer try your code on this page

https://id.sonyentertainmentnetwork.com/signin/

Try using autofocus

<input type="text" name="myInput" autofocus />

https://www.w3schools.com/tags/att_autofocus.asp

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