0
我想通過javascript自動填充表單。現在,我遇到的問題是,在填寫完這些文本框後,我將其重點放在了另一個文本框中,我填寫的所有文本都已清除並清空了文本框?有人能告訴我爲什麼這樣做,以及我如何通過它。JS自動填寫表單,文本框清除焦點?
JS:
window.setTimeout(function() {
document.getElementsByClassName("_ph6vk _623pz _o716c")[0].focus();
}, 1000);
window.setTimeout(function() {
document.getElementsByClassName("_ph6vk _623pz _o716c")[0].value = "some value 0";
}, 2000);
window.setTimeout(function() {
document.getElementsByClassName("_ph6vk _623pz _o716c")[1].focus();
}, 3000);
window.setTimeout(function() {
document.getElementsByClassName("_ph6vk _623pz _o716c")[1].value = "some value 2";
}, 4000);
HTML:
<form class="_asaim">
<div class="_fhskl">
<div class="_j5suk"></div>
<div class="_hxmdu">
or
</div>
<div class="_j5suk"></div>
</div>
<div class="_agqzm">
<div class="_sjplo _8ki4j">
<input aria-describedby="" aria-label="Mobile Number or Email" aria-required="true" class="_ph6vk _623pz _o716c" name="emailOrPhone" placeholder="Mobile Number or Email" type="text" value="d">
<div class="_gaby6">
<span class="coreSpriteInputError _eyp7r"></span>
</div>
</div>
</div>
<div class="_agqzm">
<div class="_sjplo _8ki4j">
<input aria-describedby="" aria-label="Full Name" aria-required="false" class="_ph6vk _623pz _o716c" name="fullName" placeholder="Full Name" type="text" value="d">
<div class="_gaby6">
<span class="coreSpriteInputAccepted _eyp7r"></span>
</div>
</div>
</div>
<div class="_agqzm">
<div class="_sjplo _8ki4j">
<input aria-describedby="" aria-label="Username" aria-required="true" class="_ph6vk _623pz _o716c" maxlength="30" name="username" placeholder="Username" type="text" value="d">
<div class="_gaby6">
<span class="coreSpriteInputError _eyp7r"></span>
</div>
</div>
</div>
<div class="_agqzm">
<div class="_sjplo _8ki4j">
<input aria-describedby="" aria-label="Password" aria-required="true" class="_ph6vk _623pz _o716c" name="password" placeholder="Password" type="password" value="d">
<div class="_gaby6">
<span class="coreSpriteInputError _eyp7r"></span>
</div>
</div>
</div>
<div>
<span class="_9mno0 _ov9ai"><button class="_qv64e _gexxb _4tgw8 _njrw0"><span class="_9mno0 _ov9ai">Sign up</span></button></span>
</div>
<p class="_fd2m9"><!-- react-text: 144 -->By signing up, you agree to our <!-- /react-text --><a class="_nzfks" href="/legal/terms/" target="_blank">Terms</a><!-- react-text: 146 --> & <!-- /react-text --><a class="_nzfks" href="/legal/privacy/" target="_blank">Privacy Policy</a><!-- react-text: 148 -->.<!-- /react-text --></p>
</form>