I've been hacking a little WordPress plug-in here, to make it work as I like, and I have this line to which I would like to add a class.
here is the js, that works in console, but never works inline on the page or anywhere else:
document.addEventListener('DOMContentLoaded', function() {
jQuery(function($) {
const perf = document.querySelector('[aria-label="Europe marker"]');
$(perf).addClass("POP");
console.log("custom variable perf is:", perf); ///
$('.POP').click(function() {
//
var x = $(".mapplic-layer-down");
var y = $(".mapplic-visible");
//
console.log($(x).attr("data-floor")); // print x
console.log($(y).attr("data-floor")); // print y
// switch classes
$(x).removeClass("mapplic-layer-down, mapplic-hidden");
$(x).addClass("mapplic-visible");
$(y).removeClass("mapplic-visible");
$(y).addClass("mapplic-layer-down, mapplic-hidden");
});
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a class="mapplic-pin pin-pulse pin-label" aria-label="Europe marker" style="top: 24.65%; left: 48.7%; background-color: rgb(0, 84, 135); border-color: rgb(0, 84, 135); transition: transform 0s ease 0s; transform: scale(3);" data-location="1972"><span><span>9</span></span></a>