我无法让此代码正常工作,我正在尝试将我的所有输入字段定位为具有onblur和onfocus效果,但根本没有成功。请帮助我。
我也尝试使用getElementsByClassName但它没有用...... :(
var inputArray = new Array( "ans01", "ans02", "ans03", "ans04", "ans05", "ans06" );
for( var i = 0; i < inputArray.length; i++ ) {
answerInput = document.getElementById(inputArray[x]).value;
}
var inputField = answerInput;
inputField.onfocus = function() {
if (inputField.value == "Place your answer here") {
inputField.value = "";
}
};
inputField.onblur = function() {
if (inputField.value == "") {
inputField.value = "Place your answer here";
}
};