Consumer confidence soared in November to prerecession levels, a survey released Tuesday shows.

The consumer-confidence index rose to 107.1, the highest since July 2007, the Conference Board said Tuesday. The index had reached a 20-month high of 103.5 in September but pulled back in October to a revised 100.8.

Economists polled by MarketWatch had expected the index to rise to 102 in November from an initial October estimate of 98.6.

U.S. stocks, namely the S&P 500 index SPX, -2.37% and the Dow Jones Industrial Average DJIA, -1.92% , which had been trading near break-even levels in the morning before the confidence data was released, edged slightly higher afterward.

The jump in confidence couldn't directly be tied to the victory of President-elect Donald Trump. Most of the consumers were surveyed before the election at a time when Democratic challenger Hillary Clinton was widely seen as the favorite.

However, Lynn Franco, director of economic indicators at the Conference Board, said the small sample of postelection responses showed that consumers’ optimism wasn't dimmed by Trump’s victory.

Stephen Stanley, chief economist at Amherst Pierpont, said data show a natural flurry of optimism following elections.

“This campaign was so acrimonious that having the election over may have had people feeling better,” he said.

The present situation index, a measure of current conditions, increased to 130.3 from 123.

The labor market didn’t lift confidence as consumers outlook for the labor market was mixed. The number of people who anticipated more jobs in the months ahead was virtually unchanged while the percentage who expected jobs to be scarce fell slightly.

The future expectations index increased to 91.7 from 86.0.