我怎么能知道用户点击其中<立GT;从code选项在asp.net背后 [英] How can i know that the user click which <li> option from code behind in asp.net

查看:97
本文介绍了我怎么能知道用户点击其中<立GT;从code选项在asp.net背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有两个<李> 里面的物品< UL>

 < UL =服务器>
  <李=服务器>名称和LT; /李>
  <李=服务器>类型< /李>
< / UL>

如何知道用户从服务器上点击该选项,如果用户单击名称,我需要知道的点击产品name.Is有什么办法来检查使用ASPX用?


解决方案

 < UL ID ='myList中'>
  <李ID ='1'>首先< /李>
  <李ID ='2'>第二个< /李>
  <李ID ='3'>三< /李>
  <李ID =4>四< /李>
  <李ID ='5'>五< /李>
< / UL>$(#myList上礼)。点击(函数(){
    警报(this.id); //通过直接访问一个DOMElement物业编号点击华里
    警报($(本).attr('ID')); // jQuery的.attr()方法,相同的,但更详细
    警报($(本)的.html()); //被点击华里的innerHTML
    警报($(本)的.text()); //得到李点击文本内容
});

Suppose I have two <li> items inside <ul>.

<ul runat="server">
  <li runat="server">Name</li>
  <li runat="server">Genre</li>
</ul>

How can i know which option the user was clicked from server,if user clicked Name,i need to know the clicked item is name.Is there is any way to check using aspx with?

解决方案

<ul id='myList'>
  <li id='1'>First</li>
  <li id='2'>Second</li>
  <li id='3'>Third</li>
  <li id='4'>Fourth</li>
  <li id='5'>Fifth</li>
</ul>

$("#myList li").click(function() {
    alert(this.id); // id of clicked li by directly accessing DOMElement property
    alert($(this).attr('id')); // jQuery's .attr() method, same but more verbose
    alert($(this).html()); // gets innerHTML of clicked li
    alert($(this).text()); // gets text contents of clicked li
});

这篇关于我怎么能知道用户点击其中&LT;立GT;从code选项在asp.net背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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