美文网首页
处理图像2

处理图像2

作者: 味蕾里的青春 | 来源:发表于2016-10-19 23:23 被阅读27次

    ].parentNode',document.images[i].parentNode.tagName)
    if (document.images[i].parentNode.tagName=="A"){
    setupRollover(document.images[i]);
    }
    }
    }

    function setupRollover(thisImage) {
    // console.log('setupRollover',thisImage)
    var defaultUrl = thisImage.src;
    thisImage.onmouseover=function () {
    //console.log('vghgg')
    thisImage.src="../img/"+thisImage.id+"arrow.jpg";
    }

    thisImage.onmouseout=function () {
        thisImage.src=defaultUrl;
    }
    
    thisImage.onclick=function() {
        thisImage.src="../img/"+thisImage.id+"three.gif";
    }
    

    }

    
    
    
     ###4.由链接触发翻转器
    html:
    
    
    
    

    <!DOCTYPE html>
    <html>
    <head lang="en">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-scale,initial-scale=1">
    <link type="text/css" rel="stylesheet" href="../css/simple Rollover.css">
    <script type="text/javascript" src="../js/link rollover.js"></script>
    <title>link Rollover</title>
    </head>
    <body>
    <h1>
    <a href="http://hicc.me/" id="arrow">Next page</a>
    </h1>
    <img src="../img/bluearrow.jpg" id="arrowImg" alt="arrow">
    </body>
    </html>

    
    
    
    js:
    
    
    
    
    

    window.onload=rolloverInit;
    function rolloverInit() {
    for(var i=0;i<document.links.length;i++){
    var defaultlink=document.links[i];
    if (defaultlink) {
    var defaultimg=document.getElementById(defaultlink.id+"Img");
    if(defaultimg){
    setupRollover(defaultlink,defaultimg);
    }
    }
    }
    }

    function setupRollover(thisLink,thisImg){
    var defaultUrl=thisImg.src;
    thisLink.onmouseover=function(){
    thisImg.src="../img/red"+thisLink.id+".jpg";
    }

    thisImg.onmouseout=function(){
        thisImg.src=defaultUrl;
    }
    
    thisImg.onclick=function(){
        thisImg.src="../img/green"+thisLink.id+".jpg";
    }
    

    }

    相关文章

      网友评论

          本文标题:处理图像2

          本文链接:https://www.haomeiwen.com/subject/gjffuttx.html