kagorastidis
10/18/2016 - 11:01 AM

Replace existing class with the one of your choosing. Works well when you want to change a standard icon with a google material icon etc.

Replace existing class with the one of your choosing. Works well when you want to change a standard icon with a google material icon etc.

var _replaceClass = (elem, className, text) => {
	try {
		var prevClass = jQuery(elem).attr('class').split(' ');
		if(prevClass !=='') {
			for(var i=0; i<prevClass.length; i++) {
				if(text.length > 0) {
					jQuery(elem).removeClass(prevClass[i]).addClass(className).text(text);
				}
				else {
					jQuery(elem).removeClass(prevClass[i]).addClass(className)
				}
				
			}
		}
	} catch(e) {
		return null;
	}
}