Difference between revisions of "Team:BNU-China/Integrated Practices"

Line 11: Line 11:
 
         <div class="practice-main">
 
         <div class="practice-main">
 
             <div class="practice-link-left"><a href="#"> Preface </a></div>
 
             <div class="practice-link-left"><a href="#"> Preface </a></div>
             <img src="https://static.igem.org/mediawiki/2016/2/22/T--BNU-China--practice1.jpg" class="practice-img">
+
             <img src="https://static.igem.org/mediawiki/2016/2/22/T--BNU-China--practice1.jpg" class="practice-img" id="img1">
 
             <!--<a href="#">We visited here.</a>-->
 
             <!--<a href="#">We visited here.</a>-->
 
         </div>
 
         </div>
Line 54: Line 54:
 
     document.querySelector('div#practice').style.backgroundImage='url("https://static.igem.org/mediawiki/2016/a/a6/T--BNU-China--sky2.jpg")';  
 
     document.querySelector('div#practice').style.backgroundImage='url("https://static.igem.org/mediawiki/2016/a/a6/T--BNU-China--sky2.jpg")';  
 
}
 
}
 +
 +
function getElementLeft(element){
 +
    var actualLeft = element.offsetLeft;
 +
    var current = element.offsetParent;
 +
    while (current !== null){
 +
        actualLeft += current.offsetLeft;
 +
        current = current.offsetParent;
 +
    }
 +
    return actualLeft;
 +
}
 +
function getElementTop(element){
 +
    var actualTop = element.offsetTop;
 +
    var current = element.offsetParent;
 +
    while (current !== null){
 +
        actualTop += current.offsetTop;
 +
        current = current.offsetParent;
 +
    }
 +
    return actualTop;
 +
}
 +
 +
var img = $('#img1');
 +
var top = getElementTop(img);
 +
var left = getElementLeft(img);
 +
alert(top);
 +
  
  
 
</script>
 
</script>
 
</html>
 
</html>

Revision as of 14:52, 12 October 2016

Team:BNU-CHINA - 2016.igem.org