Inner text as a class
by Matthew Day
HTML
<div>heythere</div>
<div>waz</div>
CSS
.heythere {
color: crimson;
}
.waz {
color: thistle;
}
JavaScript
(function($) {
var client = {
init: function() {
client.getStuff();
},
getStuff: function() {
var temp = document.getElementsByTagName('div');
$.each(temp, function(i, val) {
var temp2 = $(val).text();
$(val).addClass(temp2);
});
}
}
$(window).load(function() {
client.init();
});
})(window.jQuery);
// JS finds the text in between the opening and closing tags and then uses that text as a class on said div. Why would we ever want to do this? Because SharePoint is stupid.