如何在updatepanel中为outter HTML标记调用jquery函数 [英] How to call jquery function in updatepanel for outter HTML tag

查看:82
本文介绍了如何在updatepanel中为outter HTML标记调用jquery函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个消息框。它将使用AJAX更新面板每1秒刷新一次。

i有一个消息框滚动条的DIV(ID = cont)标签.DIV标签位于更新面板的外面。

在jQuery函数的帮助下,滚动条始终位于底部。

现在问题是当新消息到达时滚动条不会自动降下来。

i我试图调用jQuery函数在updatepanel中是这样的:



i have a message box. it will refresh for every 1 sec with AJAX updatepanel.
i have a DIV (ID=cont) tag for message box scrollbar.the DIV tag is out side of the updatepanel.
Scrollbar positioned always bottom by the help of jQuery function.
now the problem is when new message was arrived the scrollbar not come down automatically.
i am tried to call jQuery function in updatepanel like this:

Sys.Application.add_load(updateDiv);





但没有用。



我尝试过:





but no use.

What I have tried:

<form id="form2" runat="server">
    <div class="div" id="div" runat="server">
        <div id="cont" runat="server" class="cont">

        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>

        <asp:DataList ID="dt" runat="server" class="dt" onitemdatabound="dt_ItemDataBound">
        <ItemTemplate>

                 <p class="p" id="name" runat="server" style="margin-top:0px; display:none"><%#Eval("username") %></p>
                
                 <div class="div1" id="div1" runat="server">
                 <div id="message" runat="server" class="message"><%#Eval("message") %></div>
                 </div>

        </ItemTemplate>
        </asp:DataList>

        <asp:Timer ID="Timer1" runat="server" OnTick="GetTime" Interval="1000" />
        </ContentTemplate>
        </asp:UpdatePanel>

    </div>


    <div class="div2">
    <asp:TextBox ID="message" runat="server" TextMode="MultiLine" placeholder="Type Message" class="textbox"></asp:TextBox>
    <asp:Button ID="send" runat="server" Text="Send" class="send" 
            onclick="send_click" />
    <asp:RequiredFieldValidator ControlToValidate="message" ID="RequiredFieldValidator1" runat="server" ErrorMessage="Type message" ForeColor="Red"></asp:RequiredFieldValidator>
    </div>
    </div>
        <script src="Scripts/jquery.min.js" type="text/javascript"></script>
        <script type="text/javascript">
        
        var objDiv = document.getElementById("cont");
        objDiv.scrollTop = objDiv.scrollHeight;
        function updateDiv() {
            $("#here").load(window.location.href + " #here");
        }
    </script>
    </form>

推荐答案

(#here)。load(window.location.href +#这里);
}
< / script>
< / form>
("#here").load(window.location.href + " #here"); } </script> </form>


m new to Javascript and jQuery. I want to click a button and have a js function executed. (For this example, it's just an alert, but it's actually an ajax function.)

The first alert appears, but after I click the button, I never see the second ("did it") alert. It looks like javascript doesn't think the doIt() function is defined when the button is clicked.

Here's the relevant code:


(document).ready(function()
{
alert('ready');

函数doIt(){
alert('did it');
};
}


<体>
< input name =Gotype =buttonvalue =Goonclick =doIt();/>
< / body>
(document).ready(function() { alert('ready'); function doIt() { alert('did it'); }; } ) <body> <input name="Go" type="button" value="Go" onclick="doIt();"/> </body>


这篇关于如何在updatepanel中为outter HTML标记调用jquery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆