CheckBoxList中如何让鼠标选中的对象改变背景颜色 CheckBoxList中如何让鼠标选中的对象改变背景颜色,说明白点就是鼠标单击哪个item,把这个item的背景色给变一下,不是checkbox选中的对象变颜色,哪位朋友帮忙指导一下 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 根据鼠标事件的(e)来找到当前item 改之 mousehover 事件,根据sender试试判断出是哪个item,或者用数组记录下item的坐标进行判断,手头没工具,只能这么说了。 ChickListBox,鼠标选择的项好像本来和别的就不一样。如果想要选中的项颜色不同估计要自己重写控件中绘制Item的函数了。 即使不考虑改变颜色,我现在对于怎么判断鼠标点击了哪个item也是一头雾水 <asp:CheckBoxList ID="CheckBoxList1" runat="server"> <asp:ListItem Text="呵呵" Value="0" onclick="if(this.checked)this.parentNode.childNodes[1].style.backgroundColor='red';else this.parentNode.childNodes[1].style.backgroundColor='';"></asp:ListItem> <asp:ListItem Text="哈哈" Value="1" onclick="if(this.checked)this.parentNode.childNodes[1].style.backgroundColor='red';else this.parentNode.childNodes[1].style.backgroundColor='';"></asp:ListItem> </asp:CheckBoxList> 为什么这么写不好用呢<asp:CheckBoxList ID="CheckBoxList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="name" DataValueField="name" OnSelectedIndexChanged="Check_Clicked" AutoPostBack="True" BackColor="AntiqueWhite" BorderStyle="Ridge" > <asp:ListItem Selected="True" onclick="if(this.checked)this.parentNode.childNodes[1].style.backgroundColor='red';else this.parentNode.childNodes[1].style.backgroundColor='';"></asp:ListItem> </asp:CheckBoxList> 谢谢wzy_love_sly的回答,代码没问题,可是我问的并不是让checked的对象变色,而是让鼠标点的某一对象变色,就是鼠标点哪个对象,哪个对象变背景颜色 jmail接收邮件,附件当成正文显示 想问一下关于'的作用(或意思) C#读去配置文件 关于Flash控件的使用问题 flowlayout 如何取得sqlserver数据库中各表之间的关系? .net web项目安装与部署 请问如何给自定义类和方法什么的加上注释? 怎么使用DataTable的select方法来实现多列排序,急! 关于数据库更新的问题!帮帮忙,50分就是你的啦! 怎样把汉字转换成utf8内码? 文件的独占问题
如果想要选中的项颜色不同估计要自己重写控件中绘制Item的函数了。
<asp:ListItem Text="呵呵" Value="0" onclick="if(this.checked)this.parentNode.childNodes[1].style.backgroundColor='red';else this.parentNode.childNodes[1].style.backgroundColor='';"></asp:ListItem>
<asp:ListItem Text="哈哈" Value="1" onclick="if(this.checked)this.parentNode.childNodes[1].style.backgroundColor='red';else this.parentNode.childNodes[1].style.backgroundColor='';"></asp:ListItem>
</asp:CheckBoxList>
<asp:CheckBoxList ID="CheckBoxList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="name" DataValueField="name" OnSelectedIndexChanged="Check_Clicked"
AutoPostBack="True" BackColor="AntiqueWhite" BorderStyle="Ridge" >
<asp:ListItem Selected="True" onclick="if(this.checked)this.parentNode.childNodes[1].style.backgroundColor='red';else this.parentNode.childNodes[1].style.backgroundColor='';"></asp:ListItem>
</asp:CheckBoxList>
就是鼠标点哪个对象,哪个对象变背景颜色