jQuery dynamic toggle class function
You can access the data element via dataset property and camelCase data name

const data = element.dataset.classToggle;


You can add a click event to the document as follows that will only do something if the target is class js_class_toggle

const togClass = `.js_class_toggle`;

addEventListener("click", e =&gt; {
    if (e.target.classList.contains(togClass)) {
        /* ...do stuff... */
    }
}


Or you can add a click to each element containing the class.

document.querySelectorAll(togClass).forEach(el =&gt; el.addEventListener("click", toggleClick));


By the looks you are toggling the class on the element that is clicked so there is no need to add the reference

&lt;div class="js_class_toggle toggle-me" data-class-toggle="toggle-me"&gt;
    This element will have a class toggled
&lt;/div&gt;


making the function to toggle very simple

function toggleClick(e) {
     e.target.classList.toggle(e.target.dataset.classToggle);
}


To include the reference id you can make the data JSON like

&lt;div id = "foo" class="js_class_toggle toggle-me" 
    data-class-toggle='{"query": "#foo", "toggleClass": "toggle-me"}'&gt;
    This element will have a class toggled
&lt;/div&gt;


Then the function becomes

function toggleClick(e) {
     const data = JSON.parse(e.target.dataset.classToggle);
     const el = document.querySelector(data.query);
     if (el) { el.classList.toggle(data.toggleClass) }
}