两段源代码的顺序不一样居然导致运行结果不一样。请各位帮忙指出问题。
源代码如下:<script type="text/javascript">
//添加作者
var current=1;
function new_author()
{
old=current;
current=current + 1;
//设置插入的内容
str1="<div id=s" + current + "><li>作者" + current + "<input type=text maxlength=10 size=10 name=author/></li></div>";
strX="s"+ old;
eval("document.all." + strX + ".insertAdjacentHTML(\"AfterEnd\",str1)");
}
</script></head>
<body>
<ul>
<div id="s1">
<li id="del_li">
作者1:
<input type="text" maxlength="30" size="10" name="author" />
<button onclick="return new_author()">添加作者</button>
<button onclick="return del_author()">删除作者</button>
</li>
</div> <li>
通信作者:
<input type="text" maxlength="30" size="10" name="communication_author" />
</li>
<ul>
</body>这段代码运行没有任何问题。但是把<li>通信作者...</li>这段代码放到<div id="s1">...</div>这段代码前面去,运行时出现错误:用于此项操作的原始HTML无效。<script type="text/javascript">
//添加作者
var current=1;
function new_author()
{
old=current;
current=current + 1;
//设置插入的内容
str1="<div id=s" + current + "><li>作者" + current + "<input type=text maxlength=10 size=10 name=author/></li></div>";
strX="s"+ old;
eval("document.all." + strX + ".insertAdjacentHTML(\"AfterEnd\",str1)");
}
</script></head>
<body>
<ul>
<li>
通信作者:
<input type="text" maxlength="30" size="10" name="communication_author" />
</li> <div id="s1">
<li id="del_li">
作者1:
<input type="text" maxlength="30" size="10" name="author" />
<button onclick="return new_author()">添加作者</button>
<button onclick="return del_author()">删除作者</button>
</li>
</div>
<ul>
</body>请问这是为什么?
我的环境是win xp sp2 + IE6。
源代码如下:<script type="text/javascript">
//添加作者
var current=1;
function new_author()
{
old=current;
current=current + 1;
//设置插入的内容
str1="<div id=s" + current + "><li>作者" + current + "<input type=text maxlength=10 size=10 name=author/></li></div>";
strX="s"+ old;
eval("document.all." + strX + ".insertAdjacentHTML(\"AfterEnd\",str1)");
}
</script></head>
<body>
<ul>
<div id="s1">
<li id="del_li">
作者1:
<input type="text" maxlength="30" size="10" name="author" />
<button onclick="return new_author()">添加作者</button>
<button onclick="return del_author()">删除作者</button>
</li>
</div> <li>
通信作者:
<input type="text" maxlength="30" size="10" name="communication_author" />
</li>
<ul>
</body>这段代码运行没有任何问题。但是把<li>通信作者...</li>这段代码放到<div id="s1">...</div>这段代码前面去,运行时出现错误:用于此项操作的原始HTML无效。<script type="text/javascript">
//添加作者
var current=1;
function new_author()
{
old=current;
current=current + 1;
//设置插入的内容
str1="<div id=s" + current + "><li>作者" + current + "<input type=text maxlength=10 size=10 name=author/></li></div>";
strX="s"+ old;
eval("document.all." + strX + ".insertAdjacentHTML(\"AfterEnd\",str1)");
}
</script></head>
<body>
<ul>
<li>
通信作者:
<input type="text" maxlength="30" size="10" name="communication_author" />
</li> <div id="s1">
<li id="del_li">
作者1:
<input type="text" maxlength="30" size="10" name="author" />
<button onclick="return new_author()">添加作者</button>
<button onclick="return del_author()">删除作者</button>
</li>
</div>
<ul>
</body>请问这是为什么?
我的环境是win xp sp2 + IE6。
解决方案 »
- 求一个JS对Table的查询操作
- 如何用js文件做资源文件
- js动态创建table的问题
- 在文章中搜索关键字变色显示的问题
- 求救!!!!!!!大侠们帮帮忙!!!!!!!!!!!!
- 谁去帮忙顶一下
- 我在一页面A.htm 点击一个链接 打开新的页面B.htm,B.htm在A.htm前面 只有B.htm关了 A.htm页面才被激活 怎么实现
- 静态网页怎么在两个页面间传递静态图片参数
- 如何用代码实现“将网页另存为……”
- 请问如何在IE5.5中,用JS自定义打印时的页眉页脚(不使用其它控件)
- 从数据库取出的字段值往前台页面的表格标签中赋值
- 高手指导下 jquery 中 select 控件 ,根据text值来选中项没用
你代码给的也不全 不知道怎么帮你改
http://www.cs.tut.fi/~jkorpela/html/nesting.html
this.toolTip = new Ext.ToolTip({
target:this.getEl(),
autoHide:true,
anchor: 'bottom',
showDelay:100,
anchorToTarget:true,
trackMouse: true,
renderTo: document.body,
html:' ',
listeners: {
scope:this,
'beforeshow': function(tip) {
//alert(this.getValue());
tip.body.dom.innerHTML = this.getValue();
},
'show': function(tip){
if(tip.body.dom.innerHTML.trim() == '' || !this.toolTip){
tip.hide();
}
}
}
});
}