qTip2 jquery with asp.net textbox

2020-04-02 06:22发布

问题:

How can I implement jquery plugin qTip2 http://craigsworks.com/projects/qtip2/ with asp.net textbox? (elegant tooltip on mouseover)

<script type="text/javascript" src="../chosen/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../chosen/jquery.qtip-1.0.0-rc3.min.js"></script>
<script>
    $('tbLoginName').qtip({
        content: 'This is an active list element',
        show: 'mouseover',
        hide: 'mouseout'
    })
</script>
<asp:TextBox CssClass="textbox" ID="tbLoginName" name="tbLoginName" runat="server"/>

Here is my code, but it isn't working. What I do wrong?

Regards

回答1:

You should wait for document ready:

$(function () { //shorthand for $(document).ready(function(){...});
    $('tbLoginName').qtip({
        content: 'This is an active list element',
        show: 'mouseover',
        hide: 'mouseout'
    })
});


回答2:

Please use the below code for asp.net Textbox element.

$(function () {
    $("[id$='_txtTest']").tooltip();
});

<asp:TextBox ID="txtTest" runat="server" ToolTip="TOOLTIP"></asp:TextBox>

Definitely it will work.