data attribute
data attribute
hey guys im trying to get the value of a data attribute now ive tried different way but im not having no luck.
can you please tell me where im going wrong
- $(document).ready(function() {
var specific_count = 0;
var specific_id = 0
$('#add_specific').click(function(){
$('#specifics').append('<li id="specific_' + specific_id + '"><input type="text" class="code" name="SpecificLabel[]" value="" placeholder="Label" /> <input type="text" class="code" name="SpecificData[]" value="" placeholder="Data" /><button class="remove_specific" data-specific-id="' + specific_id + '"><strong>-</strong></button></li>');
specific_count++;
specific_id++;
});
$('#specifics').on('click', '.remove_specific', function(event){
var id = $(this).data("specific-id"); // problem here
console.log(id);
//$('#specific_' + id).remove();
//specific_count--;
});
});
ive tried
- var id = $(event).data("specific-id");
and
- var id = $(event.target).data("specific-id");
thank you