To ensure proper caramelization, avoid salting the onions before they have finished cooking.
Melt butter in a large skillet over medium heat. Add onions; cook, stirring occasionally, until all juices have evaporated, about 20 minutes. Reduce heat to medium-low, and cook, stirring occasionally, until onions are very tender and golden brown, 1 hour to 1 1/2 hours. Season with salt and pepper, and serve.