javascript运行错误 1.上面的代码中 时间句柄写的不对 <button onclick="_insertNOde()">插入 </botton> 调用是_insertNode()2.liVal 这个对象 没有声明就使用了 if(liVal.value!=""){ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html> <head> <title>test </title> </head> <script type="text/JavaScript"> // function _insertNode(){ //err:_insertN "o" de()--与onclick="_insertNOde()"不一致 function _insertNOde(){ if(liVal.value!=""){ // var newNode = document.createElement(li); //err:li--加引号 var newNode = document.createElement("li"); newNode.innerText=liVal.value; // list.appendChild(newNode); //err:l“i”st--拼写(id="last") last.appendChild(newNode); } } </script> <body> <div id="last"> <li> a-1 </li> <li> b-1 </li> </div> <br/> <input type="text"id="liVal"/> <button onclick="_insertNOde()">插入 </botton> <button onclick="_removeNOde()">称除 </botton> <button onclick="_replaceNOde()">代替 </botton> </body> </html> 你的代码有几处书写格式的错误:1. <script> ... ... </script> 应该在<head></head>以内;2.</botton> 拼写错误;3._insertNOde 的O不应该大写;4.第一个和第二个<div>元素标签使用不规范;5.创建的新节点,并没有使用,append方法,添加到DOM模型中;6.本例中,在<body>体中,已经有了你的<div id="xxx"> 就不需要创建新的节点了.建议重新按照书上的例子,重新做一次. 回5楼,对于你说的第一点。<script></scriopt>应该放在<head></head>以内。不一定非要这样做有的时候如果功能不是非常复杂的话可以直接放在body里,只要保证dom可寻就行了。 Ext中json和record的转换 求JS..继承问题 鼠标移过, 播放读音(dict.cn) 请教jquery里的queue的用法 alert 的内容太多,使得 alert 框超过显示器屏幕,下面不分内容就看不到了,这个框又不能缩小,请问如何显示 我要比较两个文本输入框中的值是否相等,怎么取不到值? JavaScript解的数学建模题!高手们帮忙重构一下! 有没有可以发送命令的函数啊,象vb里的sendkey一样? 在IE中程序运行有错误?请指点! 求助Js解密,本人第一次遇见这种加密【$$=~[];$$={___:开头的】。 js 能同时复制多个内容吗?? jsp中下载时出现乱码问题
<html>
<head>
<title>test </title>
</head>
<script type="text/JavaScript">
// function _insertNode(){ //err:_insertN "o" de()--与onclick="_insertNOde()"不一致
function _insertNOde(){
if(liVal.value!=""){
// var newNode = document.createElement(li); //err:li--加引号
var newNode = document.createElement("li");
newNode.innerText=liVal.value;
// list.appendChild(newNode); //err:l“i”st--拼写(id="last")
last.appendChild(newNode);
}
} </script>
<body>
<div id="last">
<li>
a-1
</li>
<li>
b-1
</li>
</div> <br/>
<input type="text"id="liVal"/>
<button onclick="_insertNOde()">插入 </botton>
<button onclick="_removeNOde()">称除 </botton>
<button onclick="_replaceNOde()">代替 </botton>
</body>
</html>
1. <script> ... ... </script> 应该在<head></head>以内;
2.</botton> 拼写错误;
3._insertNOde 的O不应该大写;
4.第一个和第二个<div>元素标签使用不规范;
5.创建的新节点,并没有使用,append方法,添加到DOM模型中;
6.本例中,在<body>体中,已经有了你的<div id="xxx"> 就不需要创建新的节点了.
建议重新按照书上的例子,重新做一次.