asp.net 从jquery代码中生成函数

asp.net make function from jquery code

本文关键字:函数 代码 net jquery asp      更新时间:2023-09-26

我正在使用Qtip jquery插件作为我的工具提示,因为我有很多项目需要这个,所以我不想为每个项目手动执行此操作,无论如何,编码都很糟糕。

这是JS代码:

$('#<%= textlink.ClientID %>').qtip({               
    position: { 
          corner: {
                      target: 'topRight', 
                      tooltip: 'bottomLeft'
            }
              },                                    
        style:{ 
            name: 'dark',
            tip: 'bottomLeft',
            border:
              {
            width: 3,
            radius: 7
        }
    } 
});

<asp:LinkButton ID="textlink" runat="server" Text="some text" ToolTip="some other text"></asp:LinkButton>

我将有很多链接按钮对象,那么如何从上面的JS代码创建一个函数并在将鼠标悬停在链接按钮操作上时调用它?

这样做:

<asp:LinkButton cssClass="qTip" ID="textlink" runat="server" Text="some text" ToolTip="some other text"></asp:LinkButton>
$('.qTip').qtip({               
    position: { 
          corner: {
                      target: 'topRight', 
                      tooltip: 'bottomLeft'
            }
              },                                    
        style:{ 
            name: 'dark',
            tip: 'bottomLeft',
            border:
              {
            width: 3,
            radius: 7
        }
    } 
});

LinkButton上放一个类,并在jQuery中使用类选择器

<asp:LinkButton ID="textlink" cssClass="qtip" runat="server" Text="some text" ToolTip="some other text"></asp:LinkButton>
$('.qtip').qtip({               
    //...
});