高分求解ASP.NET中使用javascript遇到的麻烦
我尝试做了个网站,里面有查看新闻的功能。现在我想在页面的左端显示新闻的标题,当鼠标停留在相应的标题行上时,右端显示该新闻的摘要。显示新闻标题和摘要的代码如下:
<div class= "newsTitleBox ">
<div style= "margin-top:10px; ">
<asp:GridView ID= "GridView2 " runat= "server " AutoGenerateColumns= "False " CellPadding= "4 " ForeColor= "#333333 " GridLines= "None " ShowHeader= "False ">
<FooterStyle BackColor= "#507CD1 " Font-Bold= "True " ForeColor= "White " />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<div id= ' <%# Eval( "id ") %> ' onmousemove= "showNews(this); ">
<asp:Label ID= "Label4 " runat= "server " Text= ' <%# Eval( "title ") %> '> </asp:Label>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor= "#EFF3FB " />
<EditRowStyle BackColor= "#2461BF " />
<SelectedRowStyle BackColor= "#D1DDF1 " Font-Bold= "True " ForeColor= "#333333 " />
<PagerStyle BackColor= "#2461BF " ForeColor= "White " HorizontalAlign= "Center " />
<HeaderStyle BackColor= "#507CD1 " Font-Bold= "True " ForeColor= "White " />
<AlternatingRowStyle BackColor= "White " />
</asp:GridView>
</div>
</div>
//上面代码是左端新闻的标题部分
//下面代码是右端新闻的摘要部分
//两个部分的DIV的id都绑定到数据库中新闻的id字段,这个字段是自增的
//我想通过设置摘要部分的DIV的style属性来实现是否显示摘要
<div class= "newsContentsBox ">
<asp:GridView ID= "GridView3 " runat= "server " AutoGenerateColumns= "False " ShowHeader= "False ">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<div id= ' <%# Eval( "id ") %> ' style= "display:none ">
<div class= "newsContentTitle ">
<asp:HyperLink ID= "HyperLink2 " runat= "server " Text= ' <%# Eval( "title ") %> '> </asp:HyperLink> </div>
<div class= "newsContent ">
<asp:Label ID= "Label6 " runat= "server " Text= ' <%# Eval( "summary ") %> '> </asp:Label>
</div>
<span class= "moreNews "> <img src= "img/more.gif " /> </span>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
我现在想在JS的showNews()里面写判断代码,当鼠标停留在某个标题行时显示相应的新闻摘要,大概的代码为:
for(...)
{
DIVTitle = document.getElementById();
DIVSummary = document.getElementById();
if(DIVTitle.id != DIVSummary.id)
{
DIVSummary.style.display = "none ";
}
else
{
DIVSummary.style.display = "block ";
}
}
但具体怎么写我不清楚,我对JS了解的很少,请大家帮帮忙。