如何更改标签的文字?


175

我有一个单选按钮列表,单击单选按钮项时,我必须更改其标签的文本。但是由于某种原因,它无法正常工作。代码如下:

<asp:Label ID="lblVessel" Text="Vessel:" runat="server"></asp:Label>

<script language="javascript">
  $(document).ready(function() {

    $('#rblDiv input').click(function() {
      var selected = $("#rblDiv input:radio:checked").val();
      if (selected == "exportpack") {
        $('#lblVessel').text("NewText");
      }
    });
  });
</script>

我不是ASP.NET专家,但我认为为浏览器生成的ID不会保留您在服务器端为其提供的ID。做一个视图源,并在此处粘贴相关代码。
艾伦·拉隆德

Answers:


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.