JSFiddle - React, Tailwind, and code Playground
HTML
<a class="ajaxFormDialog" href="#">replaced link</a>
<br />
<a class="anotherlink" href="#">another link</a>
CSS
a, .ajaxFormDialog {
color: orange;
text-decoration: underline;
cursor: hand;
}
a:hover, .ajaxFormDialog:hover {
background: orange;
color: white;
}
JavaScript
var genericHandler = function(e) {
var el = $(e.target);
var href = el.data('href');
//extract data
console.log('clicked span: ',el, ' with stored href: ', href);
//do stuff here
};
$('a.ajaxFormDialog').replaceWith(function(){
var el = $(this);
console.log('replacing element: ', el);
return $("<span>").addClass('ajaxFormDialog').append($(this).contents()).
data('href', el.attr('href')). //you can store other data as well
click(genericHandler);
});