1

How can I add the data-theme value to all divs, listviews, forms, li, ul etc. from JavaScript?
Is it possible? If yes how can I do that?

Will something like the following work?

$.mobile.page.prototype.options.contentTheme= "e";
Jack
  • 10,943
  • 13
  • 50
  • 65
Piotr Krysiak
  • 2,815
  • 3
  • 23
  • 35

2 Answers2

1
Array.prototype.forEach.call(document.getElementsByTagName("*"), function (el) {
    el.setAttribute("data-theme", "e");
});
Domenic
  • 110,262
  • 41
  • 219
  • 271
1

If you have jquery-mobile included, following should work:

$.mobile.page.prototype.options.contentTheme= "e";
$.mobile.page.prototype.options.headerTheme= "e";
$.mobile.page.prototype.options.footerTheme= "e";

However if you added any elements that are not part of header, content or footer, then you should go with Domenic's way of applying for every element

Kiran
  • 5,478
  • 13
  • 56
  • 84
  • This looks better than my version, I'd think... It comes from someone who actually knows jQuery mobile :) – Domenic Sep 14 '12 at 15:59