平成30/ 2018-10-24 08:56
JAVASCRIPT/ ROLLOVER

function rollover(obj){
    if(
    obj.src
    ){
        obj.onmouseover = function(){
            this.src = this.src.replace(/_off\./, '_on.');
        }
        obj.onmouseout = function(){
            this.src = this.src.replace(/_on\./, '_off.');
        }
    }
}
window.onload = function(){
    var i, obj;
    for(i=0;i<document.getElementsByTagName('input').length;i++){
        rollover(document.getElementsByTagName('input')[i]);
    }
    for(i=0;i<document.getElementsByTagName('img').length;i++){
        rollover(document.getElementsByTagName('img')[i]);
    }
}


---------- 過去
#### ROLLOVER
function rollover(id_name){
    var obj = document.getElementById(id_name);
    if(
    obj.src.match(/_off\.[a-zA-Z]+$/)
    ){
        obj.src = obj.src.replace(/_off\.([a-zA-Z]+)$/, "_on.$1");
    } else if(
    obj.src.match(/_on\.[a-zA-Z]+$/)
    ){
        obj.src = obj.src.replace(/_on\.([a-zA-Z]+)$/, "_off.$1");
    }
}
####

<a href="javascript:void(0);" onmouseover="rollover('areaImg001');" onmouseout="rollover('areaImg001');">
<img id="areaImg001" src="/images/area_off.png" />
</a>