2017-02-11 2 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-сервера, базы данных, веб-хостинг – kritikaTalwar

+0

добавить стиль = «дисплей: нет;» к тегу, который должен быть изначально скрыт – olk

+0

olk .. thanxx alot ... –

ответ

1

Добавить стиль отображения: ни в р теге

<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> 
Смежные вопросы