I am trying to use .setAttribute on the following:
<div class="media-body">
<small>Total MA'ers found</small>
<h2 id="totalma" class="media-heading animate-number" data-value="29" data-animation-duration="1500">0</h2>
</div>
With:
document.getElementById('totalma').setAttribute("data-value", 90);
When I try this in my browser on the .htm file, it works fine. However, with Electron, it does not. The value does not change to 90. What could the issue be?
Both codes are stored in home.htm
The name of a custom data attribute in Javascript is the name of the same HTML attribute but in camelCase and with no dashes, dots, etc.
So here in your case this will work
document.getElementById('totalma').setAttribute("dataValue", 90);
You can find more information on custom data-* attribute here:- https://developer.mozilla.org/en/docs/Web/API/HTMLElement/dataset
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.