fbpx

Select list not centered after AJAX update

Overlapping colored triangles

If you have a <select> dropdown list whose contents you are clearing out and updating via a jQuery AJAX call, you may find that Internet Explorer is not recalculating its layout, and so what was once centered now looks left-aligned. A quick solution is to force IE to redraw by adding trivial whitespace after your <select>:

// clear out and re-populate dropdown
$("#my-dropdown").empty();
$.ajax({
	// ... ajax options ...
	success: function(data) {
			$.each(data, function() {
				// .. update your <select> list
			});
			// force redraw.
			$("#my-dropdown").after(' ');
	}
});

About the Author:

Visionfriendly.com

Visionfriendly.com

VisionFriendly.com has been building successful websites for over 20 years and covers all areas of website design, development and marketing with creative custom web designs and a robust in-house team of programmers to get your web marketing to work exactly the way you need it to.

Share On:

Share on facebook
Share on twitter
Share on linkedin

Comments:

Leave a Comment

Your email address will not be published. Required fields are marked *

Copyright © 2021, All Rights Reserved
Tri Colored Triangles
Scroll to Top

Take your business to the

Next Level!

Visionfriendly.com has the right team to make your business stand out from other professional websites.

Ready For Takeoff?

A Completely Customized
Digital Marketing Experience

We'll be in touch within one business day to discuss your goals and create a personalized plan that fits both you and your business.

Let’s start a Conversation