title: Setting the title attribute of an <a> tag in javascript
body: <p>I'm trying to make changes in a code which shows, "title", using jQuery, from this JavaScript code:</p>
  
  <pre><code>&lt;a id="photo" href="{%=file.url%}" title="{%=file.name%}" 
  download="{%=file.name%}" data-gallery&gt;&lt;img src="{%=file.thumbnailUrl%}"&gt;&lt;/a&gt;
  </code></pre>
  
  <p>Using this "<code>title="{%=file.name%}</code>" it shows all the name of the file (containing image type - .jpg.)</p>
  
  <p>I tried to add an id, as upper, and use:</p>
  
  <pre><code>document.getElementById("photo").setAttribute("title", "new title");
  </code></pre>
  
  <p>But I coudn't make it working. I would like add to the script:       </p>
  
  <pre><code> var title2="{%=file.name%}";
   title = (title2.slice(2, title2.length-4));    
  </code></pre>
  
  <p>To cut first 2 chars and 4 last. And then set it as a title. </p>
  
  <p>Anyone can help? </p>
  
  <p>Thanks!: )</p>
  
  <hr>
  
  <pre><code>&lt;!-- The template to display files available for download --&gt;
  &lt;script id="template-download" type="text/x-tmpl"&gt;
  {% for (var i=0, file; file=o.files[i]; i++) { %}
  
  &lt;td style="padding-left:10px; display: inline-block;" class="template-download fade"&gt;
  &lt;div align="center" class="thumbnail" class="preview"&gt;
  {% if (file.thumbnailUrl) { %}
  
  &lt;a id="photo" href="{%=file.url%}" title="{%=file.name%}" 
  download="{%=file.name%}" data-gallery&gt;&lt;img src="{%=file.thumbnailUrl%}"&gt;&lt;/a&gt;           
  
   {% } %} &lt;/div&gt;
  
  &lt;p class="name"&gt;
  {% if (file.url) { %}
  &lt;a href="{%=file.url%}"  {%=file.thumbnailUrl?'data-gallery':''%}&gt;&lt;/a&gt;
  
  {% } %}&lt;/p&gt;&lt;/td&gt;'{% } %}
  &lt;/script&gt;
  </code></pre>
  
  <p>I'am sending it couse, the &lt; a > tag is in the JS, in the body, not in clean html, and maybe document.getElementsById, and document.getElementsByName will not work here? And I don't know from where I shoud call this ID. There are small bug in this JS (')but it works! :) </p>