Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <script src="https://webrazrab.ru/sitetemplate/jquery-3.6.1.min.js"></script>
<div class="bloki">
  <div class="block">
    <div class="text">Пример с раскрытием блока следующего за кнопкой</div>
    <span class="toggle-next">Показать еще <span class="plmin plus">+</span><span class="plmin minus">-</span></span>
    <div class="text text-hide">Это текст, скрытый после кнопки</div>
  </div>
  <div class="block">
    <div class="text">
      Пример с раскрытием 
      <span class="toggle-box" data="box1">одного <span class="plmin plus">+</span><span class="plmin minus">-</span></span> или <span class="toggle-box" data="box2">другого <span class="plmin plus">+</span><span class="plmin minus">-</span></span> блока, соответствующего кнопке внутри текста
    </div>
    <div class="text text-hide box1">Это содержимое блока соответствует кнопке "одного" (box1)</div>
    <div class="text text-hide box2">Это содержимое блока соответствует кнопке "другого" (box2)</div>
  </div>
  <div class="block">
    <div class="text">
      Пример второй с раскрытием 
      <span class="toggle-box" data="box1">одного <span class="plmin plus">+</span><span class="plmin minus">-</span></span> или <span class="toggle-box" data="box2">другого <span class="plmin plus">+</span><span class="plmin minus">-</span></span> блока, соответствующего кнопке внутри текста
    </div>
    <div class="text text-hide box1">Это содержимое блока соответствует кнопке "одного" (box1)</div>
    <div class="text text-hide box2">Это содержимое блока соответствует кнопке "другого" (box2)</div>
  </div>
</div>
              
            
!

CSS

              
                .text {padding:15px 20px;border:1px solid #ccc;border-radius:20px;margin-bottom:15px;margin-top:15px}
.plmin {line-height:20px;display:inline-block;background: #fa5205;width:20px;border-radius:10px;text-align:center;font-weight:bold;color:#fff;}
.open > .plmin {background: #000;}
.minus {display:none}
.open > .plus {display:none}
.open > .minus {display:inline-block}
.toggle-box,.toggle-next {font-weight:bold;cursor:pointer;color:#fa5205}
.text-hide {display:none}
.text-hide.open {display:block}
              
            
!

JS

              
                /*1. Открыть/закрыть следующий */
/*Вариант без проверки*/
/*$('.toggle-next').click(function() {
  $(this).toggleClass('open').next().toggleClass('open');
});*/
/*Вариант с проверкой*/
$('.toggle-next').click(function() {
		if (!$(this).hasClass('open')) {
			$(this).addClass('open').next().addClass('open');
		} else {
			$(this).removeClass('open').next().removeClass('open');
		}
});
/*Открыть/закрыть по data*/
$('.toggle-box').click(function() {
  var tclass = $(this).attr('data');
  if (!$(this).hasClass('open')) {
    $(this).parents('.block').find('.open').removeClass('open');
    $(this).addClass('open').parents('.block').find('.'+tclass).addClass('open');
  } else {
    $(this).parents('.block').find('.open').removeClass('open');
  }
});
              
            
!
999px

Console