感觉js的形参和python的有点像
function easy_placeh() {
if (!Modernizr.input.placeholder) {
var input = document.getElementById("first-name");
// 代表此选框获得焦点
input.onfocus = function () {
var text = this.placeholder || this.getAttribute('placeholder');
// 好像是这个原因,如果不支持placeholder这个属性,就会导致这个属性被设置的是默认值?
if (this.value == text) {
this.value = ""
}
}
input.onblur = function () {
if (this.value == '') {
this.value = this.placeholder || this.getAttribute('placeholder');
}
else if (this.value == "cnmb") {
this.value = "12345678";
}
}
input.onblur(); //说明执行了这个动作?
}
}
function kanwo() {
var bt = document.getElementById("bt");
console.log("1")
bt.onclick = function () { //这样修改上去的onclick不会显示到源代码上,但是下面的placeholder参数会显示到上面
// 下面这样如果用for。。in。。写好像只是会修改形式参数内在的变量...如果需要真的修个input,得用数组
var input = document.getElementsByTagName("input");
for (var i = 0; i < input.length; i++) {
input[i].placeholder = "cnmb"
console.log("2")
}
// var input=document.getElementById("first-name")
// input.placeholder="123"
}
console.log("3")
}
window.onload = kanwo;//注意,这里不是document