実現したいこと
「history.back()」で前ページに戻った際、
前ページで行われたjavascriptによるclassの変更状態を再現する。
前提
想定OSはWindows、ブラウザはChromeです。
その他のチェックボックスにチェックを入れると、<tr>のclassが「other_on」に変化します。
<tr>のデフォルトのclassは「other_off」です。前ページ↓
HTML
1<input type="checkbox" name="cancellation[]" value="その他" onclick="checkdiv(this,'other')" id="8"><label for="8">その他</label> 2 3<tr id="other" class="other_off"> 4 <th></th> 5 <td></td> 6</tr>
js↓
js
1function checkdiv( obj,id ) { 2 if( obj.checked ){ 3 document.getElementById(id).classList.remove("other_off"); 4 document.getElementById(id).classList.add("other_on"); 5 } 6 else { 7 document.getElementById(id).classList.remove("other_on"); 8 document.getElementById(id).classList.add("other_off"); 9 } 10}
こちらはフォーム画面なのですが
現状、確認画面の「history.back()」で上記HTMLに戻ると、
その他のチェックボックスにチェックが入っていても<tr>のclassが「other_off」になっています。
チェックをつけて次ページへ遷移し、
その状態から「history.back()」してもclassが「other_on」になっているようにしたいです。
回答1件
あなたの回答
tips
プレビュー