NEW YORK — Justin Timberlake has some advice for taking part in the presidential election next month: Vote, but don’t take a selfie while you’re doing it.

A ballot box selfie Timberlake took as he voted in his native Tennessee earlier this week apparently violated a new state law that bars voters from taking photographs or video while they’re inside a polling place. The picture prompted a reminder of the law from state officials.

The singer and actor addressed the controversy during an appearance on “The Tonight Show” Wednesday, telling host Jimmy Fallon he thought he was inspiring people with the picture and “had no idea” it was illegal.

A recent Associated Press review found that 17 states, including Tennessee, have laws preventing ballot selfies.

The Associated Press