2017-02-11 12 views
0
<!DOCTYPE html> 
<html> 
<head> 
<script  src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
<script> 
$(document).ready(function(){ 
$("button").click(function(){ 
$("p").toggle(); 
}); 
}); 
</script> 
</head> 
<body> 

<button style="width:80%;height:35px;">Toggle between hiding and showing the  paragraphs</button> 

<p>This is a paragraph with little content.</p> 
<p>This is another small paragraph.</p> 
</body> 
</html> 

このコードは、ボタンをクリックするとdivを非表示にします。 このコードは正常に動作しています...しかし、私はそのdivが最初に隠される必要があります。クリック後に表示されます。ボタンをクリックしたときのdivの非表示と表示

+1

なぜあなたがタグ付けされているSQLサーバ、データベース、Webホスティング – kritikaTalwar

+0

追加のスタイル= "表示:なし;"最初に隠されるはずのタグに – olk

+0

olk .. thanxx alot ... –

答えて

1

追加スタイル表示:pタグでなし

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
<script> 
    $(document).ready(function(){ 
     $("button").click(function(){ 
     $("p").toggle(); 
     }); 
    }); 
</script> 
<style> 
     p{ 
      display:none; 
     } 
    </style> 
</head> 
<body> 

    <button style="width:80%;height:35px;">Toggle between hiding and showing the paragraphs</button> 

    <p>This is a paragraph with little content.</p> 
    <p>This is another small paragraph.</p> 
</body> 
関連する問題