读书人

repeater 怎么改变样式

发布时间: 2012-08-11 20:50:31 作者: rapoo

repeater 怎样改变样式
当我点击“医疗”后,改变它的背景颜色为蓝色
<asp:Repeater ID="Repe_industry" runat="server">
<ItemTemplate>
<a href="javascript:;" onclick="getIndu(<%# Eval("id") %>)" id="industry" >
<%#Eval("induName") %>
</a>
</ItemTemplate>
</asp:Repeater>


JS:
function getIndu(getValue) {
industryID.value = getValue;
document.getElementById("industry").className="current";
//为什么每次点击时只是第一行第一个的背景颜色改变呢?
}



[解决办法]
<asp:Repeater ID="Repe_industry" runat="server">
<ItemTemplate>
<a href="javascript:;" onclick="getIndu(this,<%# Eval("id") %>)" id="industry" >
<%#Eval("induName") %>
</a>
</ItemTemplate>
</asp:Repeater>


JS:
function getIndu(obj,getValue) {
industryID.value = getValue;
obj.className="current";
//为什么每次点击时只是第一行第一个的背景颜色改变呢?
}

读书人网 >asp.net

热点推荐