Answers for "document.getelementsbyclassname("detail").innerhtml"

2

js document.getelementsbyclassname modify innertext

<body>

<p class="demo">JavaScript can change the content of an HTML element.</p>    
<p class="demo">Yolo</p>   

<button type="button" onclick="myFunction()">Click Me!</button>

<script>        
function myFunction()
{
x=document.getElementsByClassName("demo");  // Find the elements
    for(var i = 0; i < x.length; i++){
    x[i].innerText="Hello JavaScript!";    // Change the content
    }

}

</script>
</body>
Posted by: Guest on March-25-2020
0

document.getElementByClassName("preview").innerHTML=src;

function update(previewPic){
/* In this function I should 
    1) change the URL for the background image of the div with the id = "image" 
    to the source file of the preview image

    2) Change the text of the div with the id = "image" 
    to the alt text of the preview image 
    */
   document.getElementById("image").setAttribute('style', 'background-image: url(' +  previewPic.getAttribute("src") + ')');
   document.getElementById("image").innerHTML = previewPic.getAttribute("alt");
}


function undo(){
    document.getElementById("image").style.backgroundImage = "";
    document.getElementById("image").title = "";
}
Posted by: Guest on May-29-2020

Code answers related to "document.getelementsbyclassname("detail").innerhtml"

Code answers related to "Javascript"

Browse Popular Code Answers by Language