<script> var funPlaceholder = function(element) { //检测是否需要模拟placeholder var placeholder = ''; if (element && !("placeholder" in document.createElement("input")) && (placeholder = element.getAttribute("placeholder"))) { //当前文本控件是否有id, 没有则创建 var idLabel = element.id ; if (!idLabel) { idLabel = "placeholder_" + new Date().getTime(); element.id = idLabel; } //创建label元素 var eleLabel = document.createElement("label"); eleLabel.htmlFor = idLabel; eleLabel.style.position = "absolute"; //根据文本框实际尺寸修改这里的margin值 eleLabel.style.margin = "7px 0 0 3px"; eleLabel.style.color = "graytext"; eleLabel.style.cursor = "text"; //插入创建的label元素节点 element.parentNode.insertBefore(eleLabel, element); //事件 element.onfocus = function() { eleLabel.innerHTML = ""; }; element.onblur = function() { if (this.value === "") { eleLabel.innerHTML = placeholder; } //checkValue(this); }; //样式初始化 if (element.value === "") { eleLabel.innerHTML = placeholder; } } }; funPlaceholder(document.getElementById("user_name")); funPlaceholder(document.getElementById("password")); </script>找到 register.tpl.htm文件,找到最下面的一行<?php TPL::output('m/footer.tpl.htm'); ?>在这行上面加入下面的代
<script> var funPlaceholder = function(element) { //检测是否需要模拟placeholder var placeholder = ''; if (element && !("placeholder" in document.createElement("input")) && (placeholder = element.getAttribute("placeholder"))) { //当前文本控件是否有id, 没有则创建 var idLabel = element.id ; if (!idLabel) { idLabel = "placeholder_" + new Date().getTime(); element.id = idLabel; } //创建label元素 var eleLabel = document.createElement("label"); eleLabel.htmlFor = idLabel; eleLabel.style.position = "absolute"; //根据文本框实际尺寸修改这里的margin值 eleLabel.style.margin = "7px 0 0 3px"; eleLabel.style.color = "graytext"; eleLabel.style.cursor = "text"; //插入创建的label元素节点 element.parentNode.insertBefore(eleLabel, element); //事件 element.onfocus = function() { eleLabel.innerHTML = ""; }; element.onblur = function() { if (this.value === "") { eleLabel.innerHTML = placeholder; } //checkValue(this); }; //样式初始化 if (element.value === "") { eleLabel.innerHTML = placeholder; } } }; funPlaceholder(document.getElementById("user_name")); funPlaceholder(document.getElementById("email")); funPlaceholder(document.getElementById("password")); </script>
这家伙很懒,还没有设置简介