标签:技术交流 文档对象模型 text 动态 ext ebs logs 常用 href
/**
* @param {String}eleId
* @param {Object}reg
*/
function checkInput(eleId,reg) {
var ele = document.getElementById(eleId);
ele.onblur = function (ev) {
if(!reg.test(this.value)){ //不匹配
this.style.borderColor = "#ff0000" //红色
}else{ //匹配
this.style.borderColor = "#cccccc" //白色
}
}
}
//验证手机号
checkInput("phone",/^13[0-9]\d{8]$/)
<div id = "testDiv">测试一个div</div>
<script>
var str = "jdi";
console.log(window.str);
console.log(document);
console.log(document === window.document);
console.log(document.childNodes);
console.log(document.head);
console.log(document.body);
console.log(document.title);
var box = document.getElementById("testDiv");
console.log(box);
console.log(box.innerText);
</script>
运行结果:
https://github.com/ruigege66/JavaScript/blob/master/D26_1_FormVerification.html
https://www.cnblogs.com/ruigege0000/
https://blog.csdn.net/weixin_44630050?t=1
JavaScript连载26-window和document
标签:技术交流 文档对象模型 text 动态 ext ebs logs 常用 href
原文地址:https://www.cnblogs.com/ruigege0000/p/13364007.html