错在这一句上了
theRowObject.cells[j].style = "",style不能直接赋值
function checkOtherTD(theTDObject)
{
var theTableObject = document.getElementById("theTable");
for(var i=0;i < theTableObject.rows.length;i++)
{
var theRowObject = theTableObject.rows[i];
for(var j=0;j<theRowObject.cells.length;j++)
{
if(theRowObject.cells[j] == theTDObject)
;
else
{
theRowObject.cells[j].style.borderLeft = "";
theRowObject.cells[j].style.borderRight = "";
theRowObject.cells[j].style.borderTop = "";
theRowObject.cells[j].style.borderBottom = "";
theRowObject.cells[j].style.padding = "";
theRowObject.cells[j].style.cursor = "";
theRowObject.cells[j].style.backgroundColor = "";
}
}
}
}
theRowObject.cells[j].style = "",style不能直接赋值
function checkOtherTD(theTDObject)
{
var theTableObject = document.getElementById("theTable");
for(var i=0;i < theTableObject.rows.length;i++)
{
var theRowObject = theTableObject.rows[i];
for(var j=0;j<theRowObject.cells.length;j++)
{
if(theRowObject.cells[j] == theTDObject)
;
else
{
theRowObject.cells[j].style.borderLeft = "";
theRowObject.cells[j].style.borderRight = "";
theRowObject.cells[j].style.borderTop = "";
theRowObject.cells[j].style.borderBottom = "";
theRowObject.cells[j].style.padding = "";
theRowObject.cells[j].style.cursor = "";
theRowObject.cells[j].style.backgroundColor = "";
}
}
}
}
解决方案 »
- ie 有没有什么办法,在文档内容发生变化时得知
- 虚心请教,Fckeditor2.6.6在PHP中应用遇到一些问题
- Java 表单验证
- 网站导航超链接点击后样式丢失了。要怎么才能一直保存?
- 求个JS广告特效
- 帮忙解释一下这个函数function table_getValue(row,col)谢谢
- jquery.uploadify上传插件修改获取文件大小的误差
- 请教一问题,javascript和html控件?
- 谁能说明style.display=='*'的全部属性,如document.all.style.display=='none'
- a标签target="_blank",怎样在新窗口中返回上一级页面
- 帮帮忙!谢谢!!
- 怎样用jsp+JAVASCRIPT实现树型菜单
<body bgcolor="#FFFFFF">
<Table>
<TR>
<TD><img src="1.gif"></TD>
<TD><img src="2.gif"></TD>
<TD><img src="3.gif"></TD>
<TD><img src="4.gif"></TD>
<TD><img src="5.gif"></TD>
</TR>
<TR>
<TD><img src="6.gif"></TD>
<TD><img src="7.gif"></TD>
<TD><img src="8.gif"></TD>
<TD><img src="9.gif"></TD>
<TD><img src="10.gif"></TD>
</TR> ......
</Table>
<script language="JavaScript">
<!--
var theImgObject = document.getElementsByTagName("img");
for(var i=0;i<theImgObject.length;i++)
{
theImgObject[i].onclick=imgClick;
}var oldObj;
function imgClick()
{
var obj = event.srcElement.parentElement;
if(typeof oldObj != "object")
{
oldObj = obj;
}
else
{
oldObj.style.borderLeft = "";
oldObj.style.borderRight = "";
oldObj.style.borderTop = "";
oldObj.style.borderBottom = "";
oldObj.style.padding = "";
oldObj.style.backgroundColor = "";
oldObj = obj;
}
addStyle(obj);
}function addStyle(obj)
{
obj.style.borderLeft = "1px solid buttonhighlight";
obj.style.borderRight = "1px solid buttonshadow";
obj.style.borderTop = "1px solid buttonhighlight";
obj.style.borderBottom = "1px solid buttonshadow";
obj.style.padding = "1px";
obj.style.backgroundColor = "#cccccc";
oldObj = obj;
}
//-->
</script>
</body>
<TR>
<TD><img src="1.gif" id=iii></TD>
<TD><img src="2.gif"></TD>
<TD><img src="3.gif"></TD>
<TD><img src="4.gif"></TD>
<TD><img src="5.gif"></TD>
</TR>
<TR>
<TD><img src="6.gif"></TD>
<TD><img src="7.gif"></TD>
<TD><img src="8.gif"></TD>
<TD><img src="9.gif"></TD>
<TD><img src="10.gif"></TD>
</TR></Table><script>
var theImgObject = document.all.theTable.getElementsByTagName("img")
for(var i=0;i<theImgObject.length;i++)
{
theImgObject[i].onclick = function()
{
checkOtherTD()
this.style.borderLeft = "1px solid buttonhighlight";
this.style.borderRight = "1px solid buttonshadow";
this.style.borderTop = "1px solid buttonhighlight";
this.style.borderBottom = "1px solid buttonshadow";
this.style.padding = "1px";
this.style.cursor = "default"
this.style.backgroundColor = "#cccccc";
}
}
function checkOtherTD()
{
var theTableObject = document.all.theTable.getElementsByTagName("TD")
for(var i=0;i < theTableObject.length;i++)
{
theTableObject[i].childNodes(0).style.cssText = ""
}
}
</script>
还有这个问题:
========================================================
function Initlize(){ var theImgObject = document.getElementsByTagName("img")
for(var i=0;i<theImgObject.length;i++){ with(theImgObject[i]){
onclick = new function(){ //new function() 和 function()这里的效果是不一样的
var theTD = parentElement checkOtherTD(src)
.....
}
}
}
}这里的 onclick = new function(){}与
onclick = function(){}写法效果是不一样的,动态表单对象添加事件我看了是onclick = new function{}
这种写法
不知道怎么回事,两者有什么区别吗?==================================================
而且必须是
with(theImgObject[i])
{
var theTD = parentElement
onclick = function(){
checkotherTD(src)
}}如果不用withvar theTD = theImgObject[i].parentElement
theImgObject[i].onclick = function{ checkotherTD(theImgObject[i].src)
}
将不认识theImgObject[i].srtc属性和方法,
能帮我解决吗?
=======================================================
马上揭帖
是使用的函数直接量至于with,两种用法是一样的,我看到你写的
theImgObject[i].onclick = function{ checkotherTD(theImgObject[i].src)
}function落下一个(),是不是这个原因
var theTD = theImgObject[i].parentElement
theTD.style.borderLeft = "1px solid buttonhighlight";
theTD.style.borderRight = "1px solid buttonshadow";
theTD.style.borderTop = "1px solid buttonhighlight";
theTD.style.borderBottom = "1px solid buttonshadow";
theTD.style.padding = "1px";
theTD.style.cursor = "default"
theTD.style.backgroundColor = "#cccccc"; theImgSrc.value = theImgObject[i].src
//checkOtherTD(theImgObject[i].src)
}
theImgSrc.value = theImgObject[i].src 这里报错~~