This is a purely motor nerve. It has two roots- cranial and spinal. The spinal root arises from the anterior horn cells of the upper five cervical segments, and it enters the skull through the foramen magnum. These fibers are joined by the cranial root which arises from the caudal part of the nucleus ambiguous and together they leave the skull through the jugular foramen with the vagus. In the jugular foramen, the cranial root fibers join the vagus to be distributed along with fibers of the vagus to the pharynx and larynx. This part of the nerve cannot be tested separately. The spinal part supplies the sternocleidomastoid and upper part of the trapezius.
image related to jugular foramen :