In the example below only one instance of substring (~code
) is replaced by a variable value.
How to replace the same inside the iframe tag, i.e. embed/~code
should be embed/92xR2fjbeUE
let file = $('#store_vid').html();
let code = '92xR2fjbeUE';
file = file.replace('~code', code);
console.log(file);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class='store' id='store_vid'>
<div class = 'vidwrap' data-code='~code'>
<iframe src='https://www.youtube.com/embed/~code?rel=0&fs=0&modestbranding=1&showinfo=0'></iframe>
</div></div>