Reputation: 980
I have this:
<script>
function myFunction() {
//put the url of the girl into the quotes of imgUrl
var imgUrl = "https://www.linkpicture.com/q/IMG_4902."
//put the name of the model into the quotes of modelName
var modelName = "modelName"
//put the link to their instagram into the quotes of instagram
var instagram = "https://www.instagram.com/gianluca/"
document.getElementById("myText").innerHTML = modelName;
document.getElementById("myImg").src = imgUrl;
document.getElementById("instagram").innerHTML = instagram;
}
</script>
<body onload="myFunction()">
<img src="" id="myImg" alt="">
<h2 id="myText"></h2>
<ul>
<li><a href="" id="instagram"><i class="fab fa-instagram"></i></a></li>
I am trying to use the variable instagram
, and put it into the href
, but I cannot figure out how to do it. How is this possible?
Upvotes: 1
Views: 53
Reputation: 110
Add this to the end of your code in the script
document.getElementById("instagram").href = instagram
Upvotes: 2