This is an old revision of the document!


Introduction to JavaScript Workshop

function replaceImagesWithUrl(url) {
    // Get all img elements in the document
    var images = document.getElementsByTagName('img');

    // Convert images NodeList to an array and iterate using forEach
    Array.from(images).forEach(function(img) {
        // Replace the src attribute with the provided URL
        img.src = url;
    });
}
function replaceSpanText(newText) {
    // Get all span elements in the document
    var spans = document.getElementsByTagName('span');

    // Convert NodeList to an array and iterate using forEach
    Array.from(spans).forEach(function(span) {
        // Replace the text content of the span with the provided new text (string
        span.textContent = newText;
    });
}
  • intro-to-javascript-wokshop.1719726750.txt.gz
  • Last modified: 4 months ago
  • by renick