Link to home
Start Free TrialLog in
Avatar of badwolfff
badwolfffFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Is is possible to condense this repeating jQuery?

I have a similar type of code that I need to repeat in jQuery about 10 times. How do I condense it?

(I've just shown you the first two repetitions):

		$('[class^="cmsms-icon-"]').removeClass(function(i, cls) {
			var target = cls.match(/(^|\s)cmsms-icon-\S+/g) || [];
			$('a', this).addClass(target[0]);
			return target[0];
		});
		$('[class^="mfcustom-icon-"]').removeClass(function(i, cls) {
			var target = cls.match(/(^|\s)mfcustom-icon-\S+/g) || [];
			$('a', this).addClass(target[0]);
			return target[0];
		});

Open in new window


thanks
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial