简体   繁体   中英

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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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