<script>
function fun(){
var str=document.all.myname.outerHTML;
document.all.myname.setAttribute("disabled",true);
}
</script>
function fun(){
var str=document.all.myname.outerHTML;
document.all.myname.setAttribute("disabled",true);
}
</script>
解决方案 »
- jquery 阻止click,mouseover,mouseout冒泡问题
- 求助!如何在页面前端操作excel
- 取 html元素样式值的疑问
- 我网页上有一个 退出登录的按扭 想要在点击它时候弹出一个有 确定和取消 的对话框 当点击确定时候关闭窗口 点取消时候不关闭 怎样写这个javascript 函数呀 那个高手给我写个
- 这个代码加上w3c就不好用了,帮忙看看
- 如何实现将一个js文件和css文件的编码转换成GBK?
- checkbox 弹出对话框简单问题
- js调用函数怎样传递参数
- 急,怎样调整滚动条的宽度!!!
- 如何获得任意一个元素的值??高手指点,50分,马上给!!!!!
- 怎么样在一页面(1.html)点一按钮,在固定的地方打开固定大小的窗口(2.html),并无提示关闭本窗口(1.html)?
- 如何取出一组checkbox的值,有一个或多个checkbox,checkbox动态生成的,多谢
在IE5中不能被执行,它还是被写成<td id=myname disabled="true">
气人
对的呀,老兄你说得很对,只能用于5。5以上的
可是在5。0的时候如何解决这个问题,
我看到用<td disabled></td>这样有效
如何实现把那个多余的东西去掉
试试吧,应该可以的,outerHTML前三个字符一定是<TD
与
<td id=myname disabled=true>
作用一样
<table border=1>
<tr >
<td id=myname>快看我</td>
</tr>
</table>
<script>
function fun(){
var str=document.all.myname.outerHTML;
document.all.myname.disabled=true
}
</script>
<td id=myname disabled="true">
与
<td id=myname disabled>后者成立,前者不成立
function fun(){
document.write("......<td id=myname disabled>.....</table>")
}
</script>
<table border=1>
<tr id=myname1 disabled style="display:none">
<td>快看我</td>
</tr>
<tr>
<td id=myname style="display:">快看我</td>
</tr>
</table>
<script>
function fun(){
document.all.myname1.style.display=''
document.all.myname.style.display='none'
}
</script>
<table border>
<tr >
<td id=myname>快看我</td>
</tr>
</table><script>
function fun(){
myname.mergeAttributes(document.createElement("<TD disabled>"))
}
</script>
<input type=button value="添加" onclick="fun()">
<table border=1>
<tr >
<td id=myname>快看我</td>
</tr>
</table><script>
function fun(){
var elm=document.all.myname;
var elm2 = document.createElement("<td disabled></td>")
elm2.innerHTML = elm.innerHTML
elm.replaceNode(elm2)
}
</script></BODY>
<table border=1>
<tr >
<td id=myname class="abc" align="left" width="100" nowrap>快看我</td>
</tr>
</table>那么。你的处理后.下面的属性
class="abc" align="left" width="100" nowrap
都丢失了
我的QQ:2469284
MSN:[email protected]可以相互交流我目前是用net_lover(孟子E章) 的方法解决
即<script>
function fun(){
document.write("......<td id=myname disabled>.....</table>")
}
</script>
重新赋值来解决的,我觉得不太好,因为我是一个大的TABLE的,我待会试下 Go_Rush(阿舜) 的mergeAttributes方法来试试,觉得应该是可以,在IE6上是没问题,下午去MM机子试试,多谢大家啦,
你的方法比我的好,我只是随便提一下其他的途径而已 :-)
这样又无法恢复? ↓myname.mergeAttributes(document.createElement("<TD>"))
alert(myname.outerHTML)
myname.removeAttribute("disabled")
alert(myname.outerHTML)
TO Go_Rush(阿舜) :
用REMOVE的方法在IE5上通不过,在IE6上没有问题,
我试了mergeAttributes这个属性,可以让元素失效,但正如前面的兄台所说,没法返回原来的有效状态用REMOVEATTRIBUTE的方法只在IE5以上版本才有用,
不知道还有其他的方法操作没有?
<input type=button value="disable" onclick="disable()">
<input type=button value="enable" onclick="enable()">
<table border=1>
<tr >
<td id=myname bgcolor=yellow>¿ì¿´ÎÒ</td>
</tr>
</table><script>
function disable(){
var elm=document.all.myname;
var elm2 = document.createElement(elm.outerHTML.match(/<td[^>]*>/i).toString().replace(/td/i,"td disabled"));
elm2.innerHTML = elm.innerHTML
elm.replaceNode(elm2)
}
function enable(){
var elm=document.all.myname;
var elm2 = document.createElement(elm.outerHTML.match(/<td[^>]*>/i).toString().replace(/ disabled/i,""));
elm2.innerHTML = elm.innerHTML
elm.replaceNode(elm2)
}
</script></BODY>
<BODY>
<input type=button value="disable" onclick="disable()">
<input type=button value="enable" onclick="enable()">
<table border=1>
<tr >
<td id=myname bgcolor=yellow>快看我</td>
</tr>
</table><script>
function disable(){
var elm=document.all.myname;
var elm2 = document.createElement(elm.outerHTML.match(/<td[^>]*>/i).toString().replace(/td/i,"td disabled"));
elm2.innerHTML = elm.innerHTML
elm.replaceNode(elm2)
}
function enable(){
var elm=document.all.myname;
var elm2 = document.createElement(elm.outerHTML.match(/<td[^>]*>/i).toString().replace(/ disabled/i,""));
elm2.innerHTML = elm.innerHTML
elm.replaceNode(elm2)
}
</script></BODY>
还原为enable用 clearAttributes
<input type=button value="add" onclick="add()">
<input type=button value="reset" onclick="reset()">
<table border>
<tr>
<td id=myname>myname<input></td>
</tr>
</table><script>
function add(){
myname.mergeAttributes(document.createElement("<TD disabled>"))
}
function reset(){
myname.clearAttributes("disabled")
}
</script>
我上班不带手册,瞎写的,Go_Rush(阿舜)的是正解。
在IE6通不过!
myname.clearAttributes("disabled") =myname.clearAttributes() 一样的把所有属性清空了
只是在vi里面写代码的时候出现了 clearAttributes方法。
我就用了,简单测试了一下见达到目的就贴上来了。现在才知道,他是清空所有属性,而且我的用法还不标准。
刚才查了一下msdnclearAttributes Method
--------------------------------------------------------------------------------
Removes all attributes and values from the object.Syntaxobject.clearAttributes()
Return ValueNo return value.ResThe clearAttributes method clears only persistent HTML attributes. The ID attribute, styles, and script-only properties are not affected.
还是emu_ston(emu) 的方法正解阿
<option>test</option>
</select><select onfocus="alert(options[-1])">
<option>test</option>
</select>第二个竟然有错!而这样又没错:
var a=[1];
alert(a[1])
alert(a[-1])控件集合的实现看来和数组真的很不同
就是那个REPLACE的法子,比用代码直接写要方便些,通用些,好啦,散分