Q:

Getting value in div and changing to a link

I have a div that gets values from the database and prints them inside a div: 
<div class="number-string">
123456789
</div>

I'm hoping to pull that value inside .number-string and change that div to a link where the href would be "https://somelink.com/123456789"
All I have right now is 
var getnumber = $('.number-string').text()

I can't figure out how to change that div and add in a variable to a link

A:

You can use the replaceWith() method to replace the div with a link.
$('.number-string').each(function(){
  $(this).replaceWith(`<a href="https://somelink.com/${this.innerText}">${this.innerText}</a>`);
})

