 <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$(function() { var xingHref = $(".contact-sm &gt; a").attr("href"); $(".contact-img &gt; a").attr("href", xingHref); });</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt; &lt;div class="contact-img"&gt; &lt;a href="https://test.de" class="evcms-open-contacts"&gt; &lt;img src="https://cdn-cache.envivo-connect.com/license/Tw3sZjz8v/p/xckYV8bESwsZ/80x80c/xckYV8bESwsZ.png?v=2.4.84-z3p37YEER-1467970717-yZUA33Hxn" alt="F. Alexander Kep" /&gt; &lt;/a&gt; &lt;/div&gt; &lt;div class="contact-sm"&gt; &lt;a href="https://www.xing.com/profile/FfAlexander" /&gt; &lt;/div&gt;</code></pre> </div> </div> </p>