ok 1 st approach is perfect you can used that in 2nd approach getElementById method does not want # before id because method knows that you put id. your 3rd approch looks ok to me i am not sure here why it does not work but if you separate those 2 operations it will work.