I am trying to remove a class from a div and simultaneously add a class. It works fine if I dont have any data attributes attached to same div (I doubt its generally about data-attributes but guess its about the ones I have as they are used to produce effects).
Since removing/adding class doesnt work along with having data-attributes, I had the idea to remove data-attributes first, then remove/add class. The removal of the d. attr. works but then still I cannot remove/add a class. (To clarify why I dont just remove data.attr. from the html: I want add/remove a class for touch devices, where I dont need the data.attr., but need to keep them for other devices.)
I couldnt really find any solution..Any ideas?Thanks!
HTML:
<div id="welcomeFrame" class='frame2 frame' data-0='transform: scale(1.0,1.0);' data-150p='transform: scale(1.3, 1.3);opacity: 1;' data-200p='opacity: 0; transform: scale(6, 6);'>
</div>
JS:
var el = document.getElementById("welcomeFrame")
el.removeAttribute("data-0");
el.removeAttribute("data-150p");
el.removeAttribute("data-200p");
$("#welcomeFrame").removeClass("frame2").addClass("newFrame");
Since removing/adding class doesnt work along with having data-attributes,That's false. The two are not related. You have another issue.