If you would at some extra commands to the script, say the command pwd (print working directory) you would see that the cd command works as expected. But after the script terminates, the calling environment is restored.
If you want to change that in a script, try sourcing it. So use
. scriptname # watch the space after the period
instead of
scriptname
|