The tree frog Dendropsophus ebraccatus utilizes a strange form of parental plasticity that is almost unique in the animal kingdom.
These parents can deposit their eggs in either terrestrial or aquatic habitats.

CC BY-SA 4.0
This is extremely rare, seeing as the adaptations for aquatic eggs are quite different than those for terrestrial ones.
In water, eggs tend to be specialized to extract oxygen.
On land, eggs are specialized to retain moisture and avoid desiccation.
The eggs of these tree frogs clearly possess a complex mix of adaptations to both environments, since they can withstand being dry or completely submerged.
Which Is The More Recent Adaptation?
The aquatic egg condition is ancestral, which makes the terrestrial condition more evolutionarily recent.
However, there are costs and benefits to laying eggs in each kind of environment.
How Do The Tree Frogs Choose Which Is Preferable?
Selection for terrestrial eggs allows for a relaxation of predation pressure from aquatic organisms. It also allows for decreased constraints on oxygen uptake. In addition, the ability to deposit eggs terrestrially in trees that hang over fast-moving streams is particularly relevant to several species of amphibians. The tadpoles can drop directly into the water body. Fast-moving waters are likely to wash egg masses away, but swimming tadpoles can control their own movements in running waters.
The main drawbacks to terrestrial egg deposition are of course exposure to terrestrial predators and the threat of desiccation. It appears that the latter factor is critical to egg deposition in this species of tree frog.
When there is no shade present (and the threat of desiccation is high), parents deposit their eggs in aquatic habitats.
When there is abundant protection from sunlight, adults lay terrestrially.
Parents can even vary their egg-laying behaviour (aquatic versus terrestrial) during the course of a single evening. This fine-tuned sophistication of egg-laying allows tree frog parents to maximize hatching success of future offspring according to immediate environmental conditions.
This post is an adapted excerpt from my book “Wild Sex: The Science Behind Mating In The Animal Kingdom“