HTML
- 7 ответов
- 0 вопросов
7
Вклад в тег
<button class="js-button" data-toggle-text="Close">Open</button>
<div class="js-container hidden">
Some text here.
</div>
.hidden {
display: none;
}
;(function($D){
var $button = $D.querySelector('.js-button'),
$container = $D.querySelector('.js-container');
$button.addEventListener('click', function(e){
var data = e.target.dataset,
toggleText = $button.innerHTML,
isVisible = $container.style.display == 'block';
$button.innerHTML = data.toggleText;
data.toggleText = toggleText;
$container.style.display = isVisible ? 'none' : 'block';
});
})(document);
$(function(){
var $button = $('.js-button'),
$container = $('.js-container');
$button.on('click', function(){
var toggleText = $(this).data('toggle-text');
$(this).data('toggle-text', $(this).text())
.text(toggleText);
$container.toggleClass('hidden');
});
});
.some-element::after {
content: url('data:image/svg+xml; base64, <тут_закодированный_svg>');
/* или */
content: url("data:image/svg+xml; utf8, <тут_код_svg>");
}