Is there a better way of doing the same thing on multiple fields?

Is there a better way to be doing this? Below is a snippet of code that I have fumbled to write so far, it works, but I would guess there has to be a better way to do it. I have a total of 12 image upload fields.

Or give all those `#someId0..2` a common class to use as JS selector, that helps with most of the repetition. Need to figure out a way to get all the `.get` urls for different images though, maybe a data attribute.

3.) I did not tackle the .get url I think using the data-attr like Dillon recommended is probably your best bet. If that’s not an option I would create an object that holds the ID and the url to .get, but adding the data attribute would be way easier.

4.) I have not check any of the code so it might be riddle with errors, but should get you started in the right direction.

5.) if you are up for the challenge you might want to try writing this in using object literal routing for your .get urls.

Tips

What now? I have some ideas for you.

Go explore CodePen!

As a front end designer and developer, you should have an account on CodePen so you can save your snippets, present your ideas, and engage with the rest other front end folk. I'd encourage you to go PRO as well, to unlock the full power of CodePen.

Get the newsletter!

You should sign up for the CSS-Tricks newsletter. It's a clean copy of all the blog posts each week, combined together, right to your inbox. If email isn't your thing, there is an RSS feed, iTunes, and lots of other ways to subscribe.

Listen to ShopTalk!

Subscribe to The Lodge!

The Lodge is a members-only, ad-free video learning area here on CSS-Tricks. Just like the free screencasts, but organized into four large complete series. Membership is also the #1 best way to support CSS-Tricks.

We can do the real footer now.

Site Links

Colophon

CSS-Tricks* is created, written by, and maintained by Chris Coyier. It is built on WordPress, hosted by MediaTemple, and the assets are served by MaxCDN. The fonts are Source Sans and Source Code Pro. It is made possible by viewers like you who subscribe to The Lodge and through advertising for products and services I like.