いくつかのjQueryコードに問題があります。フォームにいくつかのフィールドを表示しようとしていますが、ユーザーが[はい]をクリックし、[いいえ]をクリックすると非表示になる場合にのみ表示する必要があります.これは機能しますが、フィールドを表示すると、それらを互いに重ねてマウントします。私はそれに方向性を与えようとしていますが、うまくいきません。これが私のコードです:
<!DOCTYPE html>
<html>
<head>
<style>
div { background:#def3ca; margin:3px; width:80px;
display:none; float:left; text-align:center; }
</style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<label> Do you want to create a new entry? </label>
<button id="showr" type="button" >YES</button>
<button id="hidr" type="button" >NO</button>
<br/>
<div class="mydiv">
<label> Field #1
<span class="small">Describe your field</span>
</label>
<textarea rows="10" cols="40" name="" id="" ></textarea>
</div>
<div class="mydiv">
<label> Field #2
<span class="small">Describe your field</span>
</label>
<textarea rows="10" cols="40" name="" id="" ></textarea>
</div>
<script>
$("#showr").click(function () {
$("div").first().show("fast", function showNext() {
$(this).next("div").show("fast", showNext);
});
});
$("#hidr").click(function () {
$("div").hide(1000);
});
</script>
</body>
</html>
誰かがアイデアを持っているなら、私に知らせてください、ありがとう