请教一个JS的事件问题 有个td我想鼠标单击是激发一个点击事件,用JS怎么写呀? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <td onclick="a()"></a>function a() { ///} <td onclick="test()"></td>function test(){ alert("test");} 不是吧, 没这么简单吧, 我开始写了,没得效果呀。我那个TD是在Repeater里面哦。 <table width="200" border="1"> <tr> <td onclick="test()">>1</td> <td onclick="test()">>2</td> <td onclick="test()">>3</td> </tr> <tr> <td onclick="test()">一</td> <td onclick="test()">>二</td> <td onclick="test()">>三</td> </tr> </table>function test(){ alert("s")}首先td标签一定要放在table里才有效 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="DepartmentsInfo.aspx.cs" Inherits="Department_DepartmentsInfo" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title> <link href="../StyleSheet.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function test(){ alert("test"); } </script></head><body>Repeater <form id="form1" runat="server"> <div id="body"> <asp:Repeater ID="Repeater1" runat="server" onitemdatabound="Repeater1_ItemDataBound"> <HeaderTemplate> <table width="80%" border="0" align="center" cellspacing="40"><tr> </HeaderTemplate> <ItemTemplate> <td style="background-image: url(../Images/title.png); background-repeat:no-repeat; height:90px; width:100px; text-align:center;" onclick="test"> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/index.aspx"><span style="font-size:30px; text-align:center;"><%#DataBinder.Eval(Container.DataItem, "depart_Name")%></span></asp:HyperLink> </td> </ItemTemplate> <FooterTemplate> </tr></table> </FooterTemplate> </asp:Repeater> </div> </form></body></html>放了, tr是在后台动态生成的, 你们写一个TD看有不有用 <td onclick="JavaScript:test()"></td> td style="background-image: url(../Images/title.png); background-repeat:no-repeat; height:90px; width:100px; text-align:center;" onclick="test">onclick="test()"要带括号的 那要怎么样在test()里面获取被点击单元格的值呢 。。 在线等 回答了这个就给分 <html> <body> <table border = 1> <tr> <td onclick = "alert(this.innerHTML)">111</td> </tr> </table> <body></html>试试看 <html> <head> <script type="text/javascript"> function aaa(zhi) { alert(zhi); } </script> </head> <body> <table border = 1> <tr> <td onclick = "aaa(this.innerHTML)">111</td> </tr> </table> <body></html> jquery中右下角弹出类QQ消息框用法 现在播新闻的都喜欢在屏幕上指指划划,如何实现的? 设置属性 为何ff下是undefined 一个关于history.go(-1)的问题 100分求解一个兼容w3c标准的问题 innerhtml效果瞬间消失! 总结一下ActiveX 控件的使用技巧 请问有在WEB下打印报表的方法吗?或则控件。免费的 ASP.NET Ajax 客户端框架未能加载 jQurey的mouseenter事件 如何屏蔽javascript中windows弹出窗口的关闭按钮? 求教:限时提交按钮
///
}
function test(){
alert("test");
}
我那个TD是在Repeater里面哦。
<table width="200" border="1">
<tr>
<td onclick="test()">>1</td>
<td onclick="test()">>2</td>
<td onclick="test()">>3</td>
</tr>
<tr>
<td onclick="test()">一</td>
<td onclick="test()">>二</td>
<td onclick="test()">>三</td>
</tr>
</table>
function test(){
alert("s")
}首先td标签一定要放在table里才有效
<head runat="server">
<title>Untitled Page</title>
<link href="../StyleSheet.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function test(){
alert("test");
}
</script>
</head>
<body>Repeater
<form id="form1" runat="server">
<div id="body">
<asp:Repeater ID="Repeater1" runat="server"
onitemdatabound="Repeater1_ItemDataBound">
<HeaderTemplate>
<table width="80%" border="0" align="center" cellspacing="40"><tr>
</HeaderTemplate>
<ItemTemplate>
<td style="background-image: url(../Images/title.png); background-repeat:no-repeat; height:90px; width:100px; text-align:center;" onclick="test">
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/index.aspx"><span style="font-size:30px; text-align:center;"><%#DataBinder.Eval(Container.DataItem, "depart_Name")%></span></asp:HyperLink>
</td>
</ItemTemplate>
<FooterTemplate>
</tr></table>
</FooterTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
放了, tr是在后台动态生成的, 你们写一个TD看有不有用
要带括号的
<body>
<table border = 1>
<tr>
<td onclick = "alert(this.innerHTML)">111</td>
</tr>
</table>
<body>
</html>试试看
<head>
<script type="text/javascript">
function aaa(zhi)
{
alert(zhi);
}
</script>
</head>
<body>
<table border = 1>
<tr>
<td onclick = "aaa(this.innerHTML)">111</td>
</tr>
</table>
<body>
</html>