JSFiddle - React, Tailwind, and code Playground

by Rafael Alberto Barata Gámez

HTML

<div class="bar"></div>
    <div class="foo" data-test="value1"></div>

JavaScript

testSelector = function () {
    var matched = $(':data(test)');
    console.log(matched);
    console.log('You matched ' + matched.length + ' elements');
};

testSelector();
$("div.bar").data('test', 'value2');
testSelector()
console.log($("div.foo").data('test'));
testSelector()