Answer the question
In order to leave comments, you need to log in
How to display dynamically created data attributes in the Mozilla inspector?
When adding elements dynamically, data attributes are not displayed in the inspector (ctrl+shift+c).
var o = $('<option>1</option>');
o.attr('value', 2);
o.data('rate', 3);
$("#shipping_methods").append(o);
<select id="shipping_methods" name="shipping_id">
<option value="2">1</option>
</select>
Answer the question
In order to leave comments, you need to log in
In jQuery, .data is not a true data attribute. They are used only the first time they are used for padding and are ignored afterwards.
Either use Element.dataset or duplicate the attributes manually.
Well, the most important question - why do you need it?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question