刚来一个新公司 看代码时看的我有的纠结
比如代码中是这样写的document.getElementById("txtTest").printView();
这个printView() 我始终么想得到怎么实现 怎么实现呢 必须是 document.getElementById("txtTest").方法 的形式
在线等 只要贴代码 测试过的
比如代码中是这样写的document.getElementById("txtTest").printView();
这个printView() 我始终么想得到怎么实现 怎么实现呢 必须是 document.getElementById("txtTest").方法 的形式
在线等 只要贴代码 测试过的
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>google map</title>
</head>
<body>
<div id='txtTest'></div>
</body>
<script type="text/javascript">
HTMLElement.prototype = {
printView : function(){
this.innerHTML = '123123123123'
}
}
window.onload = function(){
document.getElementById("txtTest").printView();
}
</script>
</html> ie下只能每次给每个元素加了
<html>
<head>
<title>test</title>
<script language="javascript">
HTMLInputElement.prototype.printView = function(){alert(0);};
</script></style></head>
<body onload="setInitFoucs()">
<input type="text" id="test"/>
<input type="button" value="test" onclick="document.getElementById('test').printView();"/>
</body>
</html>
<html>
<head>
<title>test</title>
<script language="javascript">
HTMLInputElement.prototype.printView = function(){alert(0);};
</script></style></head>
<body>
<input type="text" id="test"/>
<input type="button" value="test" onclick="document.getElementById('test').printView();"/>
</body>
</html>
这种方式不行啊