$('button').click(function(e) {
console.log(this.closest('section').className);
});
<span data-id="1" class="vsp-ive" style="background: #8BC34A;" title="" > <b>БЛОК 1-55</b></span>
<span data-id="2" class="vsp-ive" style="background: #8BC34A;" title="" ><b>БЛОК 1-99</b></span>
<span data-id="3" class="vsp-ive" style="background: #8BC34A;" title="" ><b>БЛОК 1-77</b></span>
<span data-id="4" class="vsp-ive" style="background: #8BC34A;" title="" ><b>БЛОК 1-RR</b></span>
<span data-id="1" class="swa-age" title="10 " data-value="10 "><img src="10.png" alt="10 "><b>БЛОК 1-5</b></span>
<span data-id="2" class="swa-age" title="9" data-value="9"><img src="9.png" alt="9"><b>БЛОК 1-9</b></span>
<span data-id="3" class="swa-age" title="25" data-value="25" ><img src=" " alt=" ">БЛОК 2-5 </span>
<span data-id="4" class="swa-age" title="45" data-value="45" ><img src=" " alt=" "> БЛОК 2-9 </span>
$(document).on('click', '.swa-age', function() {
$('.vsp-ive[data-id="'+$(this).data('id')+'"]').click();
});
function myFunction() {
let x = document.getElementsByClassName("dropdown-content");
let i;
for (i = 0; i < x.length; i++) {
x[i].classList.toggle('show');
}
}
$(document).ready(function () {
$('a#link1, a#link2').click(function (e) {
$(this).toggleClass('active');
if ($(this)[0].id == 'link1') $('#content1').toggle();
else $('#content2').toggle();
e.stopPropagation();
});
$('#content1, #content2').click(function (e) {
e.stopPropagation();
});
$('body').click(function () {
var link = $('a#link1');
if (link.hasClass('active')) {
link.click();
}
var link2 = $('a#link2');
if (link2.hasClass('active')) {
link2.click();
}
});
});