How to Change the Contents ("value") of a Custom Attribute

23 views Asked by At

I have the following HTML5 Custom Attribute:

<input ... class="my-input" data-counted="N">

How do I change its value (from "N" to "Y") in jquery?

Here is what I have and it does not work:

$(document).on('change', '.my_input', function() {
    $(this).attr('data-counted').val('Y');
});
1

There are 1 answers

1
Mohamed-Yousef On BEST ANSWER

you can use

$(this).attr('data-counted','Y');

or

$(this).data('counted','Y');