一部の入力フィールドが水平に1行に整列したフォームがあります。エラーがあった場合、エラーが発生した入力要素にスクロールしたいが、コンテナを設定できない#preferences
scrollLeft。はjavascriptでdiv.scrollLeftを設定できません
<form id="preferences">
<input type="text" value="" placeholder="" id="new_username" name="username"/>
<input type="text" value="" placeholder="aww:/ add an email" id="email" name="email"/>
<input type="password" value="" placeholder="password" id="old_password" name="password"/>
<input type="password" value="" placeholder="new password" id="new_password" name="new_password"/>
<input type="submit" value="update">
</form>
#preferences {
text-align: center
margin: 10px 0;
white-space: nowrap;
overflow-x: auto;
}
var email = document.getElementById('email'),
preferences = document.getElementById('preferences');
preferences.scrollLeft = email.offsetLeft;
あなたが設定することはできません何を意味するのですか?何かエラーが出るのですか、まったく効果がありませんか? '#preferences'とは何ですか?どのようなスタイルを持っていますか?より具体的にマークアップとCSSを表示してください。 – Gabriel
何も起こらず、エラーもありません。更新された質問をご覧ください。 @Gabriel –