简体   繁体   English

如何使用jQuery在asp.net的列表视图中找到“ a href”标签

[英]How to find “a href” tag inside a List View in asp.net using jquery

I need to find anchor tag in side a <asp:ListView> using jquery. 我需要使用jquery在<asp:ListView>找到anchor标记。 Sample code is given below. 示例代码如下。

<asp:ListView ID="lstview" runat="server">
 <ItemTemplate>
  <tr>
   <td class="col-item-actions">
    <a id="aShare" runat="server" href="#modal-share" class="button button-small modal-trigger">Share</a>
   </td>
  </tr>
 </ItemTemplate>
</asp:ListView>

I need to find the anchor tag and change its href dynamically using jquery. 我需要找到anchor标记并使用jquery动态更改其href

Can any body please help me to solve this. 有谁可以帮我解决这个问题。

Thanks. 谢谢。

$("#'<%=ListView.ClientID %>'").find("a").attr("href","srt your href");

参考属性

Since you have classes assigned. 由于您已分配课程。 You could try: 您可以尝试:

$("#<%= lstview.ClientID %> .button").attr("href","yourhref");

or 要么

$("#<%= lstview.ClientID %> .button-small").attr("href","yourhref");

Notice the lstview.ClientID because this is dynamically generated id. 注意lstview.ClientID因为它是动态生成的ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM