[英]Unable to retrieve offset for a ASP.NET server-side control
I'm trying to retrieve the offsetHeight of a server-side control but it gives me an error. 我正在尝试检索服务器端控件的offsetHeight,但它给了我一个错误。 Here's the following code snippet - 这是以下代码片段-
function Test() {
var imgFavorite = $("<%= imgFavorite.ClientID %>"); //imgFavorite is a server-side asp:Image control.
alert(imgFavorite); //[object Object]
alert(imgFavorite.offsetHeight()); //undefined.
}
What is wrong with the code? 代码有什么问题?
使用ID声明jQuery对象时,您已经错过了哈希值:
var imgFavorite = $("#<%= imgFavorite.ClientID %>");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.