選択ドロップダウンから選択が行われたときにdivを表示するjqueryスクリプトがあります。それはうまく動作しますが、私はどのようにページをリロードした後、ページにdivを保持するのだろうかと思っていた。ここではスクリプトは次のとおりです。divを非表示にしてからページをリロードした後にdivを保持
$(document).ready(function() {
$("select").change(function() {
var color = $(this).val();
if (color == "Yes") {
$(".box").not(".Yes").hide();
$(".Yes").show();
} else if (color == "No") {
$(".box").not(".No").hide();
$(".No").show();
} else {
$(".box").hide();
}
});
});
<div>
Is this to be a subdomain?<select name="setweb">
\t \t <option selected disabled>Please Select</option>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div>
<br />
<div class="Yes box" style="display:none">
<input type='text' class='text' name='business' size='20' />Enter your subdomain in the text box.
</div>
<div class="No box" style="display:none">
<input type='text' class='text' name='business' size='20' />Enter your domain in the text box.
</div>
<br/>
あなたの助けをありがとうございました。
あなたはcookieまたはlocalstorageのような場所に変更を保存する必要があります。 – j08691
またはPHPで基本的なGETまたはPOST要求を実行してください... – hallleron