Tengo un div donde hay un atributo HTML llamado data-theme dentro. Quiero preguntar cómo cambio el valor del atributo llamado data-theme . Por ejemplo: From: data-theme="dark" to data-theme="light" . El valor se almacena en una variable como una cadena.
Mi div :
<div id="myId" data-theme="dark"></div>Quiero usar JavaScript normal.
document.getElementById("myId").setAttribute("data-theme", "newValue")