Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何在按钮单击事件中调用此Jquery函数?_Asp.net_Jquery_Vb.net - Fatal编程技术网

Asp.net 如何在按钮单击事件中调用此Jquery函数?

Asp.net 如何在按钮单击事件中调用此Jquery函数?,asp.net,jquery,vb.net,Asp.net,Jquery,Vb.net,我想在ASP.NET中的按钮单击事件中调用此jquery函数 var doRedirect = function() { location.href='http://www.example.com' }; $("#button1").click(function() { $("#label1").show(); window.setTimeout("$('#label1').fadeOut('slow', doRedirect)", 10000); }); 如果jQuery是内

我想在ASP.NET中的按钮单击事件中调用此jquery函数

var doRedirect = function() { location.href='http://www.example.com' };
$("#button1").click(function() {
    $("#label1").show();
    window.setTimeout("$('#label1').fadeOut('slow', doRedirect)", 10000);
});

如果jQuery是内联的,则可以执行以下操作:

var doRedirect = function() { location.href='http://www.example.com' };
$("#<%=button1.ClientId%>").click(function() {
    $("#<%=label1.ClientId%>").show();
    window.setTimeout("$('#<%=label1.ClientId%>').fadeOut('slow', doRedirect)", 10000);
});

注意,我使用输出HTML元素类型作为jQuery选择器中的子元素

在.net中,您可以将其称为属性,对吗??
<div id="myId">
   <asp:Label runat="server" id="label1" />
   <asp:Button runat="server" id="button1" />
</div>

var doRedirect = function() { location.href='http://www.example.com' };
$("#myId input").click(function() {
    $("#myId span").show();
    window.setTimeout("$('#myId span').fadeOut('slow', doRedirect)", 10000);
});