My brother bought a D5100 body only a few days ago and I've given him my 18–55 kit lens (I have a D3300). Today his focus stopped working (he might have fiddled with the settings a bit, I'm not sure). Neither the focus ring nor the autofocus works. I tried putting the lens back on my camera and it focuses perfectly. I tried putting a different lens on his camera and it also focuses (using either manual or auto). Only when I put the 18–55 on his camera does it stop working. What should I do?
You should check that the contacts are clean. These transmit power and control information from the camera body to the lens. I suspect that there's something interfering on either the lens or body that just happens to not align problematically with the slightly-different fit of another lens, or this lens on another camera body.
As a first pass, try microfiber cloth. If that doesn't work, you could also try isopropyl alcohol, but be very, very careful to not drip that into the camera.