0
我有codepen驗證碼:https://codepen.io/RaoniSousa/pen/Zpkxbb:替代這在Javascript
var x = document.querySelectorAll('.label'), //label com ID label,
z = document.querySelectorAll('.input'); //input com ID name;
function myFunction() {
'use strict';
if (this.value !== "") {
this.style.opacity = '1';
this.style.bottom = '4em';
this.style.color = '#722872';
console.log(this);
} else {
this.style.opacity = '0';
this.style.bottom = '1.5em';
console.log(this);
}
}
在功能上面,我想只改變標籤(VAR X)的風格。我知道「這」指的是。輸入(VAR Z),但是,我想申請一個樣式標註爲我改變了他的相關輸入值,但如果我使用一個for循環,他稱所有標籤都是同一時間。有沒有辦法通過使用'this.style'或其他人知道此代碼的另一種替代方法來調用var z的var z intead?
我想它的工作原理是在這裏發生(滾下來吧,直到達到聯繫我部分):https://codepen.io/freeCodeCamp/pen/YqLyXB
在此先感謝。