title: Get data-value from element in another file with jQuery
body: <p>So basically I have some elements with some data-values in a file . I want to dynamically create links to them using those data-values to type the <em>text</em>, <em>href</em> etc.</p>
  
  <p>For example, I have two divs, id'ed <code>first</code>and <code>second</code>.  They have <code>importance</code> values, respectively "most important" and "least important".</p>
  
  <p>I want to create two links to them, with the phrase "This is a link to the most/least important div" using JavaScript/jQuery. Below is a non-working example.</p>
  
  <p>File <code>a.html</code> (ommiting headings and such, ofc):</p>
  
  <pre><code>&lt;div id='first' data-importance='most important'&gt;This is the first div.&lt;/div&gt;
  
  &lt;div id='second' data-importance='least important'&gt;This is the second div.&lt;/div&gt;
  </code></pre>
  
  <p>File <code>b.html</code>:</p>
  
  <pre><code>&lt;p&gt;&lt;a class='makelink' data-linkto='first'&gt;&lt;/a&gt;&lt;/p&gt;
  
  &lt;p&gt;&lt;a class='makelink' data-linkto='second'&gt;&lt;/a&gt;&lt;/p&gt;
  
  $(`.makelink`).each( function(){
    var target = $(this).data('linkto');
    $(this).attr('href','b.html#' + target);
    var imp = $('b.html #' + target).data('importance'); 
    $(this).html('Link to the ' + imp + ' div');
  });
  </code></pre>
  
  <p>However nothing happens. Any help is appreciated.</p>