|
|
|
| Вот есть код (Jquery) он просто скрывает и раскрывает блок (плавно или быстро - в зависимости от параметра). Как это можно реализовать на чистом JS?
<style>
.block1{
cursor: pointer;
text-decoration: underline;
background-color: #ccc;
border: 1px solid #888;
margin-top: 5px;
padding-left: 10px;
}
.block2{
border: 1px solid #ccc;
padding: 5px;
margin-bottom: 10px;
display: none;
}
</style>
|
<script type="text/javascript">
$(document).ready(function(){
$(".block1").toggle(function(){
$(this).next().slideDown();
}, function(){
$(this).next().slideUp();
});
});
</script>
|
<div class="block1">Это блок 1 - он раскрывает и скрывает блок 2!</div>
<div class="block2">Это блок 2</div>';
|
| |
|
|