Is a Nikon D3100 lens compatible with a Nikon D40x body?

I have a Nikon D40x SLR camera and I accidently dropped my 18-55mm lens and want to buy a new one on ebay.
I believe the lens I have found is identical but the description says it is for a D3100 and I'm just wondering if the lenses are interchangeable on Nikon camera bodies?
In short… Will the new lens work on the older body?

Yes it is compatible and I believe it is exactly the same lens.

All Nikon DSLR bodies can safely mount all Nikkor lenses built since 1977 with 1 or 2 exceptions
Pre AI lenses built before 1977 can be safely AI converted to allow them to mount
some consumer level DSLR bodies can also mount Pre AI glass withouit risk
the only thing to be concerned about regardinhg recent vintage lenses and DSLRs is wether or not the lens will Auto Focus
AF lenses require a Focus motor built into the body while AF-S lense [ as well as AF-I lenses ]
have a focus motor in the lens controlled via CPU contacts
the only 18-55 mm lenses nikon ever built are all AF-S so yes the lens in question is 100% compatible
this chart may be handy for future referance http://www.photosynthesis.co.nz/nikon/lenses.html

Yes, all entry level Nikon DSLR's share the same mount
- NIKON D40X ON EBAY- is this worth it for £189 body only? - 1
- I want to buy a Nikon D40x (body only)?
- Are there any camera lenses with an internal motor that are compatible with a Nikon D40x?
- Can i use the Nikon 50mm 1.4d lens with my nikon D5300 camera body? Is it compatible?
- Is the Nikkor 70-300mm F/4.5-5.6 Lens compatible with the Nikon D40 camera body?