To recognize the possibility of hydrogen bonding, examine
the Lewis structure of the molecule. The electronegative atom
must have one or more unshared electron pairs as in the case
of oxygen and nitrogen, and has a negative partial charge. The
hydrogen, which has a partial positive charge tries to find another
atom of oxygen or nitrogen with excess electrons to share and
is attracted to the partial negative charge. This forms the basis
for the hydrogen bond.
In other words - The hydrogen on one molecule attached
to O or N that is attracted to an O or N of a different molecule.
In the graphic on the left, the hydrogen is partially positive
and attracted to the partially negative charge on the oxygen.
Because oxygen has two lone pairs, two different hydrogen bonds
can be made to each oxygen.
This is a very specific bond as indicated. Some combinations
which are not hydrogen bonds include: hydrogen to another hydrogen
or hydrogen to a carbon.
Link to animation of Hydrogen
Bonding in Water - Northland Community and Technical College