javascript - Creating links for all letters of the alphabet -
i want put alphabet on top of page. when clicks on letter, small json file containing words starting letter loaded.
how create letters seperate id's on top of page, without manually typing 26 of them?
i've found this code in php want achieve:
for ($i = 65; $i <= 90; $i++) { printf('<a href="%1$s.html" class="myclass">%1$s</a> ', chr($i)); }
how 1 in javascript?
in javascript use fromcharcode
var html = '', chr = ''; (var = 65; <= 90; i++) { chr = string.fromcharcode(i); html+= '<a href="'+ chr +'.html" class="myclass">'+ chr +'</a> '; }
Comments
Post a Comment