简体   繁体   中英

Get value from asp:RadioButton on mouseover

I have a asp:RadioButton inside a asp:GridView:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" GridLines="None">
 <Columns>
    <asp:TemplateField>
     <ItemTemplate>
      <asp:RadioButton ID="RB" runat="server" Text='<%#Eval("Name").ToString() %>' AutoPostBack="true"/>
     </ItemTemplate>
    </asp:TemplateField>
 </Columns>
</asp:GridView>

I can change the background-color like this:

$(function () {
 $("[id*=GridView1] td").hover(function () {
    $("td", $(this).closest("tr")).addClass("hover_row");
  }
});

but I don't know how to extract the value of the RadioButton on mouseover. I tried using the val() function but I always get 'undefined'

尝试

var myval = label[for='" + $(this).find("input:radio").attr("id") + "']").text();

我必须使用text()而不是val():

$("td", $(this).closest("tr")).text();

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