I'm adding data attributes and classes to a <a>
: if I hardcode this attributes/classes it works, but if I add them dynamically it doesn't work.
An event should be fired when clicking the <a>
I have this HTML:
<a id="get_started" href="#price_table">
<button class="btn action_button btn-sm active">Get Started</button>
</a>
And this jQuery:
$(document).on('touchstart click', '.target > li > a', function(e){
category = 'books';
if(category=='books') {
$('#get_started').addClass('btn_response').addClass('md-trigger').attr('data-subject', category).attr('data-modal', 'modal_response').attr('href','#');
}
});
Doesn't dynamically data attributes give the same effects than if I hardcode them?