对于横幅,我需要把一个图片显示在同一个页面上。我真的很差-所以,我用这种方式-但是,确实,它不起作用.
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="ad.size" content="width=300,height=600">
<title>Stack</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
</head>
<body>
<a id="clickThroughBtn" href="javascript:window.open(window.clickTag)">
<div id="border">
<div id="container">
<div class="border2">
<div id="logo_bg"></div>
<div id="red_c" class="logo_element"></div>
<div id="rays" class="logo_element"></div>
<div class="logo"><img src="logo_fr.svg" alt="Cofidis" /></div>
<div class="title">
Test
<div id="adaptive">
<script>
function getImgs(){
var Adaptive = document.getElementsByID('thumb0').img;
Adaptive[0].style.width="200px"; // Taille de l'image
Adaptive[0].style.width="200px"; // Hauteur
}
</script>
</div>
</div>
</div>
</div>
</a>
<img id="thumb0" src="http://gmz2.zarbi.be/avatars/m/1/1116.jpg?1404045273.jpg" />
</html>最重要的部分-
<!-- Adaptive -->
<div id="adaptive">
<script>
function getImgs(){
var Adaptive = document.getElementsByID('thumb0').img;
Adaptive[0].style.width="200px"; // Taille de l'image
Adaptive[0].style.width="200px"; // Hauteur
}
</script>
</div>
<!-- Adaptive -->谢谢大家!卢多维奇
发布于 2015-09-21 10:43:29
你需要改变这一点:
var Adaptive = document.getElementsByID('thumb0').img;
Adaptive[0].style.width="200px"; // Taille de l'image
Adaptive[0].style.width="200px"; // Hauteur对此:
var Adaptive = document.getElementById('thumb0');
Adaptive.style.width="200px"; // set image width
Adaptive.style.height="200px"; // set image height因为在document对象中没有这样的方法getElementsByID。
另外,getElementById返回一个元素。如果您需要获得多个对象,那么getElementsByName,getElementsByClassName和getElementsByTagName将为您工作。
https://stackoverflow.com/questions/32692964
复制相似问题