行和列...... [英] row and column...

查看:67
本文介绍了行和列......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,


我有这个,


< table>

< colgroup>

< col id =" column1" />

< col id =" column2" />

< col id =" column3" />

< / colgroup>

< tr onmouseover =" do hi-light" onmouseout =" undo hi-light">

< td>< / td>

< td>< / td>

< td>< / td>

< / tr>

< / table>


我可以在前两列上进行高亮照明,除了最后一次鼠标

移动行,但现在我想不要在最后一次点亮行

列已经结束了,因为我在最后一列上有三个单独的链接

cell。当一行被选中时,是否可以知道选择了哪一列?我不想在其中设置任何属性< td>

我可以在onmouseover / out函数中检查它吗?


问候,

Wandy

解决方案

Wandy Tang写道:

亲爱的,

我有这个,

< table>
< colgroup>
< col id =" column1" />
< col id =" column2" />
< col id =" column3" />
< / colgroup>
< tr onmouseover =" do hi-light" onmouseout =" undo hi-light">
< td>< / td>
< td>< / td>
< td>< / td>
< / tr>
< / table>

我可以在前两列上点亮,除了最后一个鼠标
移动行,但是现在我想不要在最后一列结束时点亮行,因为我在最后一列
单元格上有三个单独的链接。是否可以在选择行时知道选择了哪一列?我不想在< td>中设置任何属性


为什么?试图从tr确定哪个td是mousedover

比修改td标签更困难。

我可以在onmouseover / out函数中检查吗?



onmouseover和onmouseout根本没有激发的事实。

函数名称不能包含空格,它应该包含()部分

函数调用。让我猜,你在IE测试?


-

兰迪

comp.lang.javascript常见问题 - http://jibbering.com/faq


< blockquote>


Wandy Tang写道:

我有这个,

< table>
< colgroup>
< col id =" column1" />
< col id =" column2" />
< col id =" column3" />
< / colgroup>
< tr onmouseover =" do hi-light" onmouseout =" undo hi-light">
< td>< / td>
< td>< / td>
< td>< / td>
< / tr>
< / table>

我可以在前两列上点亮,除了最后一个鼠标
移动行,但是现在我想不要在最后一列结束时点亮行,因为我在最后一列
单元格上有三个单独的链接。是否可以在选择行时知道选择了哪一列?我不想在其中设置任何属性< td>
我可以在onmouseover / out函数中查看它吗?




我不确定我有没有理解你想要的东西,但这里有一个例子

检查< td>的cellIndex属性元素:


<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 // EN"

" http:// www .w3.org / TR / html4 / strict.dtd">

< html lang =" en">

< head>

< title> cellIndex< / title>

< script type =" text / javascript">

功能高亮显示(row,evt,backgroundColor ){

var sourceElement;

if(evt.srcElement){

sourceElement = evt.srcElement;

}

else if(evt.target){

sourceElement = evt.target;

if(sourceElement.nodeType!= 1){

sourceElement = sourceElement.parentNode;

}

}

if(sourceElement == row&& row .style){

row.style.backgroundColor = backgroundColor;

}

else {

var targetCell = sourceElement;

while(targetCell&& targetCell.tagName.toLowerCase()!=''td''){

targetCell = targetCell.parentNode;

}

if(targetCell&& targetCell.cellIndex!= 2){

row.style.backgroundColor = backgroundColor;

}

}

}

< / script>

< / head>

< body>

< table border =" 1">

< tbody>

< tr onmouseover =" highlight(this,event,''lightblue'');"

onmouseout =" highlight(this,event,'''')">

< td>

0,0

< / td>

< td>

0,1

< / td>

< td>

0,2

< a href =" http://JavaScript.FAQTS.com/"> ; JavaScript.FAQTs.com< / a>

< / td>

< / tr>

< / tbody>

< / table>

< / body>

< / html>


这样整行(< tr>)改变了backgroundColor,但只有当你将鼠标移到第一个或第二个单元格上时才会改变它。

-


Martin Honnen
http://javaScript.FAQTs.com/


Martin Honnen于2004年5月5日在comp.lang.javascript中写道

Wandy Tang写道:

我可以在前两列上进行高亮操作,除了最后一个鼠标移动行时,但现在我想要当最后一列结束时,不要点亮行
,因为我在最后一列单元格上有三个单独的链接。当选择行时,是否可以知道选择了哪一列?我不想在< td>里面设置任何属性
我可以在onmouseover / out函数中检查它吗?
我不确定我是否理解你想要的东西但是这里有一个例子
检查< td>的cellIndex属性。元素:

<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 // EN"
" http://www.w3.org/TR/html4 /strict.dtd">
< html lang =" en">
< head>
< title> cellIndex< / title>
< script type =" text / javascript">
函数highlight(row,evt,backgroundColor){
var sourceElement;
if(evt.srcElement){
sourceElement = evt。 srcElement;
}
如果(evt.target){
sourceElement = evt.target;
if(sourceElement.nodeType!= 1){
sourceElement = sourceElement .parentNode;
}
}如果(sourceElement == row&& row.style){
row.style.backgroundColor = backgroundColor;
}
else {
var targetCell = sourceElement;
while(targetCell&& targetCell.tagName.toLowerCase()!=''td''){
targetCell = targetCell.parentNode ;
}
if(targetCell&& targetCell.cellIndex!= 2){
row.style.backgroundColor = backgroundColor;
}
}
}
< / script>
< / head>
< body>
< table border =" 1">
< tbody>
< tr onmouseover =" highlight(this,event ,''lightblue'');"
onmouseout =" highlight(this,event,'''')">
< td>
0,0 br />< / td>
< td>
0,1 /
< / td>
< td>
0,2 /
< a href =" http://JavaScript.FAQTS.com/"> JavaScript.FAQTs.com< / a>
< / td>
< / tr>
< / tbody>
< / table>
< / body>
< / html>




很好

这样整行(< tr>)改变了backgroundColor,但只有当你将鼠标移到第一个或第二个单元格上时才会改变它。




改变了两种情况的发生

row.style.backgr oundColor = backgroundColor;





row.firstChild.style.backgroundColor = backgroundColor;

row.firstChild .nextSibling.style.backgroundColor = backgroundColor;


-

Evertjan。

荷兰。

(请将x''es更改为我的电子邮件地址中的点数,

但请让我们继续讨论新闻组)


Dear All,

I have this,

<table>
<colgroup>
<col id="column1" />
<col id="column2" />
<col id="column3" />
</colgroup>
<tr onmouseover="do hi-light" onmouseout="undo hi-light">
<td></td>
<td></td>
<td></td>
</tr>
</table>

I can do the hi-light on the first two columns except the last when mouse
moveover the row, but now I want to not hi-lighting the row when the last
column is being over, coz I have three separate links on the last column
cell. Is it possible knowing which column is being selected when a row is
selected? I do not want to set any attribute inside <td>
Can I check it inside the onmouseover/out function?

Regards,
Wandy

解决方案

Wandy Tang wrote:

Dear All,

I have this,

<table>
<colgroup>
<col id="column1" />
<col id="column2" />
<col id="column3" />
</colgroup>
<tr onmouseover="do hi-light" onmouseout="undo hi-light">
<td></td>
<td></td>
<td></td>
</tr>
</table>

I can do the hi-light on the first two columns except the last when mouse
moveover the row, but now I want to not hi-lighting the row when the last
column is being over, coz I have three separate links on the last column
cell. Is it possible knowing which column is being selected when a row is
selected? I do not want to set any attribute inside <td>
Why? Trying to determine from the tr which td is mousedover is
tremedously more difficult than modifying the td tags.
Can I check it inside the onmouseover/out function?



The fact that the onmouseover and onmouseout fire at all is odd.
Function names can not contain spaces, and it should include the () part
of the function call. Let me guess, you are testing in IE?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq




Wandy Tang wrote:

I have this,

<table>
<colgroup>
<col id="column1" />
<col id="column2" />
<col id="column3" />
</colgroup>
<tr onmouseover="do hi-light" onmouseout="undo hi-light">
<td></td>
<td></td>
<td></td>
</tr>
</table>

I can do the hi-light on the first two columns except the last when mouse
moveover the row, but now I want to not hi-lighting the row when the last
column is being over, coz I have three separate links on the last column
cell. Is it possible knowing which column is being selected when a row is
selected? I do not want to set any attribute inside <td>
Can I check it inside the onmouseover/out function?



I am not sure I have understood what you want but here is an example
checking the cellIndex property of a <td> element:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>cellIndex</title>
<script type="text/javascript">
function highlight (row, evt, backgroundColor) {
var sourceElement;
if (evt.srcElement) {
sourceElement = evt.srcElement;
}
else if (evt.target) {
sourceElement = evt.target;
if (sourceElement.nodeType != 1) {
sourceElement = sourceElement.parentNode;
}
}
if (sourceElement == row && row.style) {
row.style.backgroundColor = backgroundColor;
}
else {
var targetCell = sourceElement;
while (targetCell && targetCell.tagName.toLowerCase() != ''td'') {
targetCell = targetCell.parentNode;
}
if (targetCell && targetCell.cellIndex != 2) {
row.style.backgroundColor = backgroundColor;
}
}
}
</script>
</head>
<body>
<table border="1">
<tbody>
<tr onmouseover="highlight(this, event, ''lightblue'');"
onmouseout="highlight(this, event, '''')">
<td>
0, 0
</td>
<td>
0, 1
</td>
<td>
0, 2
<a href="http://JavaScript.FAQTS.com/">JavaScript.FAQTs.com</a>
</td>
</tr>
</tbody>
</table>
</body>
</html>

That way the whole row (<tr>) changes the backgroundColor but only if
you move the mouse over the first or second cell.
--

Martin Honnen
http://JavaScript.FAQTs.com/


Martin Honnen wrote on 05 sep 2004 in comp.lang.javascript:

Wandy Tang wrote:

I can do the hi-light on the first two columns except the last when
mouse moveover the row, but now I want to not hi-lighting the row
when the last column is being over, coz I have three separate links
on the last column cell. Is it possible knowing which column is being
selected when a row is selected? I do not want to set any attribute
inside <td> Can I check it inside the onmouseover/out function?
I am not sure I have understood what you want but here is an example
checking the cellIndex property of a <td> element:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>cellIndex</title>
<script type="text/javascript">
function highlight (row, evt, backgroundColor) {
var sourceElement;
if (evt.srcElement) {
sourceElement = evt.srcElement;
}
else if (evt.target) {
sourceElement = evt.target;
if (sourceElement.nodeType != 1) {
sourceElement = sourceElement.parentNode;
}
}
if (sourceElement == row && row.style) {
row.style.backgroundColor = backgroundColor;
}
else {
var targetCell = sourceElement;
while (targetCell && targetCell.tagName.toLowerCase() != ''td'') {
targetCell = targetCell.parentNode;
}
if (targetCell && targetCell.cellIndex != 2) {
row.style.backgroundColor = backgroundColor;
}
}
}
</script>
</head>
<body>
<table border="1">
<tbody>
<tr onmouseover="highlight(this, event, ''lightblue'');"
onmouseout="highlight(this, event, '''')">
<td>
0, 0
</td>
<td>
0, 1
</td>
<td>
0, 2
<a href="http://JavaScript.FAQTS.com/">JavaScript.FAQTs.com</a>
</td>
</tr>
</tbody>
</table>
</body>
</html>



Nice
That way the whole row (<tr>) changes the backgroundColor but only if
you move the mouse over the first or second cell.



change both occurances of

row.style.backgroundColor = backgroundColor;

to

row.firstChild.style.backgroundColor = backgroundColor;
row.firstChild.nextSibling.style.backgroundColor = backgroundColor;

--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)


这篇关于行和列......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆