css3 :target can achieve what I did with javascript.