Categories
Website

Bootstrap 3 – Auto Apply Default Form Control Style

Remember my case? To migrate full application from Bootstrap 2 to Bootstrap 3, there are still many cases to treat such as this one, we need to place CSS class: form-control to every input, textarea and select tag, how about if we have so many files to treat?

Let’s go straight, here is a code snippet to try now:

jQuery(document).ready(function(){
	jQuery('input[type=text], textarea, select').each(function() {
		if (!jQuery(this).hasClass("form-control")) {
			jQuery(this).addClass("form-control");
		}
	});
});

 

Of course, we should have a tool to automatic modify the files to add this class, I have tried to make one but it does not work well yet.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.