The evolution of new functions takes place partially through changes in the way transcription is controlled. Transcriptional control is brought about by the interactions of transcription factors with short target motifs in the DNAs of promoters and enhancers. One way in which changes in gene expression can evolve is through the acquisition of new transcription factor targets in enhancer sequences. Since such target sites are simple, they can be produced rapidly from random DNA by mutation and selection. Here we consider a population of organisms that finds itself in an ecological situation where bringing a particular target gene under the control of a particular transcription factor would be favored by natural selection. What will be the time required for such a process, as a function of the selection for the new target, the mutation rate, and the population size? The starting sequences considered are either real enhancers from the Drosophila melanogaster genome, or randomized versions of these. We find that the time required to find binding sites is strongly dependent on the existence in the starting sequence of sites that differ from binding sites by single substitutions (presites). The process of converting presites to binding sites is driven by natural selection, and thus the time required typically reduces with the strength of selection. However, if there is a strongly distorted G:C ratio in the starting sequence, presites will typically be absent, and the finding of binding sites will be preceded by a long time period of neutral evolution, however strong is the selection favoring sites. The positions of presites largely determine where binding sites will evolve. One result of this is that any incremental selective benefits that result from the relative positioning of sites have a surprisingly small impact on the final binding-site positions.