document.querySelector('.my').addEventListener('paste', (e) => {
console.log(e);
e.preventDefault();
e.stopPropagation();
// Get the clipboard data
let paste = (e.clipboardData || window.clipboardData).getData('text');
// Твой код
});
window.onscroll = function() {
var scrolled = window.pageYOffset || document.documentElement.scrollTop,
dp1 = 500,
dp2 = 1720,
dp3 = 2287,
dp4 = 2990,
dp5 = 4007,
nav = $('.navbar-inverse'),
arrow = $('#arrow-upper');
if(scrolled >= 0 && scrolled < dp1){
if(!nav.hasClass('hide')){
nav.addClass('hide');
arrow.addClass('hide');
}
}
if(scrolled > dp1){
if(nav.hasClass('hide')){
nav.removeClass('hide');
arrow.removeClass('hide');
}
}
if(scrolled > dp1 && scrolled < dp2){
$('.nav li').removeClass('active');
$('.nav li:nth-child(1)').addClass('active');
}
if(scrolled > dp2 && scrolled < dp3){
$('.nav li').removeClass('active');
$('.nav li:nth-child(2)').addClass('active');
}
if(scrolled > dp3 && scrolled < dp4){
$('.nav li').removeClass('active');
$('.nav li:nth-child(3)').addClass('active');
}
if(scrolled > dp4 && scrolled < dp5){
$('.nav li').removeClass('active');
$('.nav li:nth-child(4)').addClass('active');
}
if(scrolled > dp5){
$('.nav li').removeClass('active');
$('.nav li:nth-child(5)').addClass('active');
}
}
$(function() {
$('.emb').each(function() {
$(this).on('click', function() {
var block = $(this).next('.meta-data'),
pinbox = $(this).parents('.pinbox');
pinbox.toggleClass('pinbox_active');
pinbox.parent().toggleClass('pinbox_parent_active');
if (pinbox.hasClass('pinbox_active')) {
block.slideDown(100);
$(document).on('click', function(event) {
if ($(event.target).closest(pinbox).length)
return;
block.hide(100);
pinbox.removeClass('pinbox_active');
pinbox.parent().removeClass('pinbox_parent_active');
event.stopPropagation();
});
}
});
});
});
* {
margin: 0px;
padding: 0px;
}
.pinbox {
position: absolute;
background-color: #2DC5F2;
width: 321px;
border-radius: 12px;
-webkit-border-radius: 12px;
position: relative;
margin: 14px 0 66px 0;
}
.pinbox_active {
-moz-transition: all 150ms linear;
-o-transition: all 150ms linear;
transition: all 150ms linear;
-webkit-transition: all 150ms linear;
z-index: 10;
box-shadow: 0 0 0.5px rgba(0, 0, 0, 0.8), 70px 50px 85px -8px rgba(57, 70, 78, 0.3);
border-radius: 12px;
-moz-border-radius: 12px;
-webkit-border-radius: 12px;
}
.pinbox_parent_active {
background: #ccc;
}
.pinbox .img {
background-color: #2DC5F2;
width: 321px;
border-radius: 12px;
-webkit-border-radius: 12px;
}
.pinbox .preview .thumb {
height: 120px;
display: block;
overflow: hidden;
position: relative;
}
.pinbox .preview .thumb img {
-webkit-border-radius: 11px 11px 0 0;
border-radius: 11px 11px 0 0;
height: auto;
max-width: 321px;
width: 100%;
}
.emb {
cursor: pointer;
position: absolute;
width: 20%;
height: 65px;
left: 50%;
transform: translateX(-50%);
}
.pinbox .meta-data {
display: none;
position: relative;
font-weight: bold;
height: 75px;
z-index: 1;
}
$(function () {
$('.emb').each(function () {
$(this).on('click', function () {
var block = $(this).next('.meta-data'),
pinbox = $(this).parent('.pinbox');
pinbox.toggleClass('pinbox_active');
if (pinbox.hasClass('pinbox_active')) {
block.slideDown(100);
$(document).on('click', function (event) {
if ($(event.target).closest(pinbox).length)
return;
block.hide();
pinbox.removeClass('pinbox_active');
event.stopPropagation();
});
}
});
});
});
Но когда я назначаю переменную в цикле, уже вне цикла эта переменная не работает