0

我有很多控件,如下所示:

                <div style="display: inline;">
                    <span id="cvCaptcha-Target" class="ttTarget">
                        <asp:CustomValidator ID="cvCaptcha" runat="server" Display="Dynamic" OnServerValidate="cvCaptcha_ServerValidate">
                            <asp:Image ID="img4cvCaptcha" CssClass="imgValidate" runat="server" AlternateText="attention"
                                ImageUrl="~/Images/Login/Exclamation.png" />
                        </asp:CustomValidator>
                    </span>
                    <div id="cvCaptcha-Content" class="ttContent">
                       captcha is incorrect!!!
                    </div>
                </div>

如您所见,我将每个控件的 ttContent 放在它的下方(在 div 内),并且我有许多带有 ttTarget 类的控件...

鼠标跟踪工具提示的 qtip2 代码如下:

        $('#target').qtip({
            content: 'i am tool tip',
            position: {
                my: 'top left',
                target: 'mouse',
                viewport: $(window), // Keep it on-screen at all times if possible
                adjust: {
                    x: 10, y: 10
                }
            },
            hide: {
                fixed: true // Helps to prevent the tooltip from hiding ocassionally when tracking!
            },
            style: 'ui-tooltip-shadow'
        });

当我们将 id 用于 qtip 时,一切都变得如此简单,我们可以轻松找到目标的内容!
但是在我的场景中,我有很多 id ,我不知道如何通过上层代码识别它们的内容!

我的意思是 :

        $('.ttTarget').qtip({
            content: '______________' -> here is my problem (how can i find ttContents),
            position: {
                my: 'top left',
                target: 'mouse',
                viewport: $(window), // Keep it on-screen at all times if possible
                adjust: {
                    x: 10, y: 10
                }
            },
            hide: {
                fixed: true // Helps to prevent the tooltip from hiding ocassionally when tracking!
            },
            style: 'ui-tooltip-shadow'
        });

提前致谢

4

1 回答 1

0

方式1:

$(function () {
            $('.ttTarget').qtip({
                overwrite: false,
                content: {
                    text: function (api) {
                        return $(this).parent('div').find('div.ttContent').html();
                    }
                },
                position: {
                    my: 'top left',
                    target: 'mouse',
                    viewport: $(window),
                    adjust: {
                        x: 10, y: 10
                    }
                },
                hide: {
                    fixed: true
                },
                style: 'ui-tooltip-shadow'
            });

方式2:

    $('.ttTarget').live('mouseover', function (event) {
        //alert($(this).next('div.ttContent').text());
        //alert($(this).parent('div').find('div.ttContent').html());
        $(this).qtip({
            overwrite: false,
            content: $(this).parent('div').find('div.ttContent').html(),
            position: {
                my: 'top left',
                target: 'mouse',
                viewport: $(window),
                adjust: {
                    x: 10, y: 10
                }
            },
            hide: {
                fixed: true
            },
            show: {
                event: event.type,
                ready: true
            },
            style: 'ui-tooltip-shadow'
        }, event);
    });
于 2011-06-07T10:09:38.393 回答