[Solved] retrieve contents of div and make image src

[ad_1]

You can simply do it in jQuery by getting the text of the div and then setting the source of image like this:

var source = $("#flag-name").text();
console.log("before - " + $("#image").attr("src"));
$("#image").attr("src",source);
console.log("after - " + $("#image").attr("src"));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="flag-name" style="hidden">en-flag.jpg</div>

<img id="image" src="https://stackoverflow.com/questions/48871589/DIV CONTENTS HERE">

1

[ad_2]

solved retrieve contents of div and make image src