2011-06-24 33 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

相关问题