2011-06-24 30 views
1

我試圖檢索服務器端控件的offsetHeight,但它給了我一個錯誤。下面的代碼片段 -無法檢索偏移量的ASP.NET服務器端控件

function Test() { 
      var imgFavorite = $("<%= imgFavorite.ClientID %>"); //imgFavorite is a server-side asp:Image control. 
      alert(imgFavorite); //[object Object] 
      alert(imgFavorite.offsetHeight()); //undefined.  
    } 

代碼有什麼問題?

回答

0

使用ID聲明jQuery對象時,你已經錯過了哈希:

var imgFavorite = $("#<%= imgFavorite.ClientID %>"); 
+0

非常感謝你。我完全錯過了! – tempid

相關問題