简体   繁体   English

jQuery高亮效果不起作用?

[英]jQuery highlight effect not working?

Here is my ascx page with embedded javascript. 这是我的带有嵌入式javascript的ascx页面。

I'd like to highlight the view which I have wrapped in a div tag (div2 for test purposes) when the view changes. 我想突出显示在视图更改时包装在div标签(用于测试目的div2)中的视图。

As of now the views change fine, but I cannot get the highlight to work. 到目前为止,视图的变化很好,但是我无法使突出显示起作用。

Is something wrong with my javascript or am I missing something else?? 我的JavaScript出了点问题吗?还是我还缺少其他东西?

Thanks 谢谢

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



<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:MultiView ID="MultiView1" runat="server">

<asp:View ID="View1" runat="server">
   <p>This is View 1</p>
   <asp:Button ID="Button1" runat="server" Text="Next" onclick="Button1_Click" />
 </asp:View>


 <asp:View ID="View2" runat="server">
    <div id="div2" style="height:auto; width:auto;">
    <p>This is View 2</p>
    <asp:Button ID="Button2" runat="server" Text="Previous" 
        onclick="Button2_Click" />  
    <asp:Button ID="Button3" runat="server" Text="Next" onclick="Button3_Click" /> 
    </div>

    <script type="text/javascript">
    $(document).ready(function () {
    $("#Button1").click(function () {
    $("#div2").effect("highlight", {}, 3000);
    });
    });
    </script>

 </asp:View>


 <asp:View ID="View3" runat="server">
    <p>This is View 3</p>
    <asp:Button ID="Button4" runat="server" Text="Previous" 
        onclick="Button4_Click1" />

 </asp:View>

 </asp:MultiView>

  </ContentTemplate>
 </asp:UpdatePanel> 

Code Behind: 背后的代码:

namespace Multiview1.Multiview1
{
public partial class Multiview1UserControl : UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(View1);
    }

   protected void Button1_Click(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(View2);
        UpdatePanel1.Update();
    }

    protected void Button3_Click(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(View3);
        UpdatePanel1.Update();
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(View1);
        UpdatePanel1.Update();
    }

    protected void Button4_Click1(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(View2);
        UpdatePanel1.Update();
    }
  }
 }

The problem appears to be loading multiple versions of jquery. 问题似乎是加载多个版本的jquery。

I've set up a fiddle to show the issue. 我设置了一个小提琴来显示该问题。 When the 2nd jquery library is commented out it works fine when it's not it doesn't work at all. 当第二个jquery库被注释掉时,它可以正常工作,否则就不能工作。

Jsfiddle 的jsfiddle

use your Button click like this 像这样使用您的按钮单击

$("#<%=Button1.ClientID%>").click(function () {
    $("#div2").effect("highlight", {}, 3000);
   });
});

As it is an asp.net control. 由于它是一个asp.net控件。

EDIT : You are going in wrong direction there is nothing wrong with the jquery click, Problem here is your div tags are inside updatepanel check this LINK 编辑:您的方向错误,jQuery单击没有问题,问题在于您的div标签位于updatepanel内,请检查此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM