Generate link based on data attributes
<p>I am trying to write a little jQuery script that checks a set of div's to see if they have a data-name attribute.  For the ones that have a data-name, it will create a link.  The href of that link should be the name of the data-value plus contain the file extension (eg.  .txt).  </p>

<p>Everything seems to work OK except when I try to add the data value onto the link.  The ultimate result of this script is to output something like this for each of those div's:  </p>

<pre><code>&lt;p class="data-link"&gt;&lt;a href="&lt;&lt;data_value&gt;&gt;.txt&gt;&gt;"&gt;Edit&lt;/a&gt;
</code></pre>

<p>Below is my script. I have identified that area that I am having issue with.  </p>

<pre><code>var dataNameWrappers = $("div#desktopSidebar div[data-name]");
dataNameWrappers.each(function() {
    var dataNameWrappers_action = "" + $(this).attr("data-name");
    $(this).prepend("&lt;p class='edit-link'&gt;&lt;a&gt;Edit&lt;/a&gt;&lt;/p&gt;");
    var dataNameWrapperEditLink = $("div#desktopSidebar p.edit-link a");
    dataNameWrapperEditLink.each(function() {
        $(this).attr('href', &lt;&lt;stuck_here&gt;&gt;);
    });
});
</code></pre>

<p>Any help will be great.  </p>

<p>Thanks</p>

<p>As requested, here is my sidebar HTMl structure</p>

<pre><code>&lt;div id="desktopSidebar"&gt;
    &lt;div class="sidebar userbox"&gt;
        &lt;h3 class="sidebarheader"&gt; Welcome  {{username}}}&lt;/h3&gt;
    &lt;/div&gt;
    &lt;div data-name="social_media_sitewide" class="sidebar socialmedia"&gt;
        &lt;h3 class="sidebarheader"&gt;Follow Tennis-Chat&lt;/h3&gt;
    &lt;/div&gt;
    &lt;div data-name="site_promotions" class="sidebar promotions"&gt;
        &lt;h3 class="sidebarheader"&gt;Current Promotions&lt;/h3&gt;
    &lt;/div&gt;
    &lt;div data-name="livescores" class="sidebar Livescores"&gt;
        &lt;h3 class="sidebarheader"&gt;Live Scores&lt;/h3&gt;
    &lt;/div&gt;
    &lt;div class="sidebar tournaments"&gt;
        &lt;h3 class="sidebarheader"&gt;Tournaments&lt;/h3&gt;
    &lt;/div&gt;
    &lt;div data-name="featured-profiles" class="sidebar profiles"&gt;
        &lt;h3 class="sidebarheader"&gt;Today's Profile: {{featured_profile_name}}&lt;/h3&gt;
    &lt;/div&gt;
    &lt;div data-name="side_advertisment" class="sidebar Advertisement"&gt;
        &lt;h3 class="sidebarheader"&gt;Advertisement&lt;/h3&gt;
    &lt;/div&gt;
    &lt;div class="sidebar Headlines"&gt;
        &lt;h3 class="sidebarheader"&gt;Tennis-Chat Headlines&lt;/h3&gt;
    &lt;/div&gt;
    &lt;div class="sidebar mostrecent" id="mostRecentTopics"&gt;
        &lt;h3 class="sidebarheader"&gt;Most Recent Posts&lt;/h3&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>
