url_for() will generate a link like this: .../static/<filename>. If you use url_for('static', filename=''), it generate a link like: .../static/, so you can just add text after it (i.e. + id + '.txt>') .

Email codedump link for How can change the name or attribute of a link in Javascript