$(document).ready(function() {
$('.reviews__text').each(function() {
if ($(this).text().length > 391) {
$(this).data('full', $(this).text() );
$(this).html($(this).text().slice(0, 391) + '... <span class="volt">'+$(this).text().slice(391, 99999)+'</span>' );
$(".volt").hide()
$(this).after("<span class='reviews__more'>Развернуть</span>");
}
});
$('.reviews__more').click(function() {
if ($(this).text() == 'Развернуть') {
$(".volt").show(function(){
$(this).addClass('animated slideInDown')
})
$(this).text('Свернуть');
} else {
$(".volt").hide(function(){
$(this).addClass('animated slideInDown')
})
$(this).text('Развернуть');
}
});
});
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css" rel="stylesheet">
<div id="player"></div>
<script src="http://www.youtube.com/player_api"></script>
<script>
// create youtube player
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: '0Bmhjf0rKe8',
events: {
onReady: onPlayerReady,
onStateChange: onPlayerStateChange
}
});
}
// autoplay video
function onPlayerReady(event) {
event.target.playVideo();
}
// when video ends
function onPlayerStateChange(event) {
if(event.data === 0) {
alert('done');
}
}
</script>