JSFiddle - React, Tailwind, and code Playground
by arcm111
HTML
<a href="#testblah" class="test" rel="image">TEST</a>
<a href="#blahtest" class="test" rel="video">TEST</a>
JavaScript
$(function () {
$(document).on("click", ".test", function (e) {
var link = $(this);
var rel = link.attr("rel");
if (rel == "image") {
e.preventDefault();
openImage(link);
} else if (rel == "video") {
openVideo(link);
}
});
function openImage(elm) {
var href = elm.attr("href");
alert(href);
}
function openVideo(elm) {
var href = elm.attr("href");
alert(href);
}
});