JQuery的不工作 [英] JQuery not working

查看:127
本文介绍了JQuery的不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的网页来实现的JQuery,但我没有能够成功地实现它。

我有一个母版页

在这里我增加了一个脚本,这已经使用由谷歌托管的jQuery菜单栏

这是在母版页本身

codeD

 <脚本类型=文/ JavaScript的SRC =htt​​p://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js >< / SCRIPT>

现在我想要实现一个jQuery设置CSS visibility属性为true或false。
在我的内容页同母版页。

 <脚本类型=文/ JavaScript的>
            $(文件)。就绪(函数(){
                $(#lnkAddMore)。点击(函数(){
                 警报();
                  }
                  );
            });
        < / SCRIPT>

本HTML控件是在我的的UpdatePanel
我不知道为什么它不工作?
我使用的UpdatePanel根据本控制。

 <输入类型=按钮ID =lnkAddMoreVALUE =添加更多/>


  

我试图用它在我的更新外
  面板它成功运行,但
  不是的UpdatePanel


我觉得这是使用它与一个UpdatePanel

问题

  

这里是我的页来源


 <脚本类型=文/ JavaScript的SRC =htt​​p://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js >< / SCRIPT>
    <链接HREF =../../ CSS / Domain.css的rel =stylesheet属性类型=文/ CSS/>
    <脚本类型=文/ JavaScript的>
        $(文件)。就绪(函数(){
            $(#lnkAddMore)点击(函数(){警报(); $('#H')隐藏(100);});
            $('#H')秀(100);
        });
    < / SCRIPT>
       < ASP:的ScriptManager ID =ScriptManager1=服务器>
        < / ASP:ScriptManager的>
        < ASP:的UpdatePanel ID =UpdatePanel1=服务器>
        <&的ContentTemplate GT;
            < D​​IV ID =divDomain=服务器>
< ASP:GridView控件/>
                < D​​IV的风格=文本对齐:权利;>
                    <输入类型=按钮ID =lnkAddMoreVALUE =添加更多/>
                < / DIV>
            < / DIV>


                     
                                                                                        
                

 < /&的ContentTemplate GT;
    < / ASP:的UpdatePanel>


解决方案

我用用jQuery和UpdatePanel的两种方法。

第一是这样的:
<一href=\"http://stackoverflow.com/questions/256195/jquery-document-ready-and-updatepanels/256253#256253\">http://stackoverflow.com/questions/256195/jquery-document-ready-and-updatepanels/256253#256253

另一种方法我在里克施特拉尔的博客(http://www.west-wind.com/Weblog/posts/154797.aspx)这是做这样的事情在后面的code发现:

  ScriptManager.RegisterClientScriptBlock(此的typeof(页),alertScript
    @$(文件)。就绪(函数(){
            $(#lnkAddMore)。点击(函数(){
             警报();
              }
              );
        });,真);

检查了这一点的一个例子:<一href=\"http://stackoverflow.com/questions/844004/problem-with-scriptmanager-registerclientscriptblock-and-jquery-in-internet-explo/844714#844714\">http://stackoverflow.com/questions/844004/problem-with-scriptmanager-registerclientscriptblock-and-jquery-in-internet-explo/844714#844714

另外看看jQuery的生活()事件订阅。

I am trying to implement JQuery in my web page but i am not been able to implement it successfully.

I have a master page

where i added one script for menu bar that is already using jquery hosted by Google

This is coded in master page itself

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>

Now i want to implement a Jquery to set the css visibility property to true or false. into my content page of same master page.

    <script type="text/javascript">
            $(document).ready(function(){  
                $("#lnkAddMore").click(function(){
                 alert();
                  }
                  );
            });
        </script>

This html control is under my UpdatePanel. I dont know why it is not working ? I am using this control under UpdatePanel.

<input type="button" id="lnkAddMore" value="Add More" />

I tried to use it outside my update panel it is running successfully but not in UpdatePanel

I think there is a problem using it with an UpdatePanel

HERE IS MY PAGE SOURCE

   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script> 


    <link href="../../Css/Domain.css" rel="stylesheet" type="text/css" /> 
    <script type="text/javascript"> 
        $(document).ready(function(){  
            $("#lnkAddMore").click(function(){alert();$('#h').hide(100);});
            $('#h').show(100);
        });
    </script> 


       <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div id="divDomain" runat="server">
<asp:gridview/>
                <div style="text-align:right;">
                    <input type="button" id="lnkAddMore" value="Add More" />
                </div>
            </div>

        </ContentTemplate>
    </asp:UpdatePanel>

解决方案

I have used two approaches with jQuery and UpdatePanels.

The first is this: http://stackoverflow.com/questions/256195/jquery-document-ready-and-updatepanels/256253#256253

The other approach I found on Rick Strahl's blog (http://www.west-wind.com/Weblog/posts/154797.aspx) Which is to do something like this in the code behind:

ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alertScript", 
    @" $(document).ready(function(){  
            $("#lnkAddMore").click(function(){
             alert();
              }
              );
        });", true);

Check this out for another example: http://stackoverflow.com/questions/844004/problem-with-scriptmanager-registerclientscriptblock-and-jquery-in-internet-explo/844714#844714

Also have a look at jQuery's live() event subscriber.

这篇关于JQuery的不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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