<asp:DataList ID="DataList1" runat="server" RepeatColumns="3">
  <ItemTemplate>
  <a>
  <div style="width: 130px; margin-top:10px; margin-left:10px;">
  <img id="images00" src="<%#Eval("Img")%>" height="70px" width="110px" alt="<%#Eval("class") %>" />
  </div>
  <span id="span1" style="display:none;"><%#Eval("ID") %></span>
  <div style="width:130px;margin-top: 5px; text-align: center;">
  详情&nbsp;&nbsp;查看
  </div>
  </a>
  </ItemTemplate>
  </asp:DataList>
$(document).ready(function () {
        $("<%#DataList1.ClientID%> tr").find("#images00").mouseover(function () {
            var id = $("<%#DataList1.ClientID%> tr").find("#span1").text();
            alert(id);
        });
    });
这样是获取到了,但是不是我想要的值,而且这个是都是一样的!!在线等待…………

解决方案 »

  1.   

    id是唯一的,你通过id去取控件 永远只能得到第一个
      

  2.   

    给你的img加个class="img-class"
    span加个class="span-class"
    id是唯一的 可以通过name或class取dom
    $(".img-class").mouseover(function(){
    alert($(".span-class",this.parentNode.parentNode).text());
    });
      

  3.   

    $(document).ready(function () {
      $("#<%#DataList1.ClientID%> tr").find("img").mouseover(function () {
          var id = $(this).parent().parent().find("span").text();
          alert(id);
      });
    });
      

  4.   

    我只是想提醒一下find效率慢,jquery可以用但是滥用就不对了