好吧,所以我們有一個簡單的用戶信息編輯頁面。我想創建一個切換按鈕,交換輪廓圖片邊界半徑從0到25和倒退。但第二部分does not work.I創建if
檢查邊境半徑25已經如此它將使0,但它並不work.Here是我的代碼更改圖片框與切換按鈕
<!DOCTYPE html>
<html>
<head>
</head>
<body onload="buildImage();">
<div class="contents" id="content"></div>
<button onclick="changeImage()">NextImage</button>
<button onclick="changeShape()">ChangeShape</button>
<button onclick="uploadImage()">Upload Image</button>
</body>
<script>
var images = [ 'profile1.png', 'profile2.png','profile3.png'];
var index = 0;
var array_length = 3;
function buildImage() {
var img = document.createElement('img')
img.src = images[index];
document.getElementById('content').appendChild(img);
}
function changeImage(){
var img = document.getElementById('content').getElementsByTagName('img')[0]
index++;
index = index % array_length;
img.src = images[index];
}
function changeShape(){
var shape = document.getElementById('content').getElementsByTagName('img')[0].style.borderRadius = "25px";
if(shape.style.borderRadius == 25){
var shape2 = document.getElementById('content').getElementsByTagName('img')[0].style.borderRadius = "0px";
}
}
function uploadImage() {
images.push("profile4.png");
array_length++;
}
</script>
</html>
任何想法,爲什麼它不工作?
改變25爲「25像素」或「25」沒question.Can你給我如何在新增寄宿生的提示工作,要麼 –