2010-07-22 17 views
1

我已經搜索過,但無法找到有效的答案。我只是想設置內容頁面中的標籤文本。顯然,因爲控件位於內容頁面中,所以它具有修改後的客戶端ID。所以我簡單地知道「.labelName」不會單獨工作,因爲客戶端ID是例如「ctl00_ContentPlaceHolder1_labelName」。需要幫助在jQuery中設置標籤(在內容頁面中)的文本道具

那麼當控件位於內容頁面時使用什麼語法?

這裏就是我有一個不工作:

function intervalTypeChanged(sender, eventArgs) { 

      var item = eventArgs.get_item(); 
      var itemText = item.get_text(); 
      if (itemText == "Seconds" || itemText == "Minutes" || itemText == "Hours") { 
       $("#trSimpleScheduleSettings").show();      
       $("#<%=lblSimpleDurationValueAfter.ClientID %>").text = itemText; 
      } 
      else { 
       $("#trSimpleScheduleSettings").hide(); 
      } 
     } 

錶行trSimpleScheduleSettings出現,但沒有在標籤沒有文字。

回答

1

.text()

$("#<%=lblSimpleDurationValueAfter.ClientID %>").text(itemText); 
+1

AAAH,我很愚蠢(對jQuery來說也是新的)。 謝謝。 – empo 2010-07-22 08:59:06

+0

嗨Reigel,對不起,但現在我已經將代碼移出到它已停止工作的.js文件。 – empo 2010-07-22 09:39:55

+0

它不會工作,因爲'<%= lblSimpleDurationValueAfter.ClientID%>'.... – Reigel 2010-07-22 09:49:23

0

除了純文本,如果你想設置標籤的像

 <b>Some Value</b>
在這種情況下,HTML形式的內容,您可以使用,當然

 
$("#<%=lblSimpleDurationValueAfter.ClientID %>").html(itemText); 
+0

它已經很明顯'itemText'是... if(itemText ==「Seconds」|| itemText ==「Minutes」 || itemText ==「小時」)' – Reigel 2010-07-22 09:04:18