Tim Butterfield
Write/Change HTML based on Image Name - Javascript

A usefull jQuery tool I created to write and change HTML elements based on an image name.

This code looks at the src of an img that has a specific class. If that image address contains a specified term, then it writes the HTML you have written to the location you set.

$('.class_name').each(function(i){
    var imgSrc = this.src;
    if(imgSrc.indexOf('image1') != -1){
        document.getElementById('Element_ID').innerHTML = 'HTML_CODE_1';
    }
    else if(imgSrc.indexOf('image2') != -1){
        document.getElementById('Element_ID').innerHTML = 'HTML_CODE_2';
    }
});
[koken_upload filename="image.png" label="image.png"]