English 中文(简体)
qtip2 tooltip - mouse tracker - how find content of many controls with a same class?
原标题:

i have many controls like below :

                <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>

as you see i put the ttContent of each control in the below of it (inside a div) and i have many controls with ttTarget class...

the qtip2 codes for mouse tracker tooltips is like below :

        $( #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 
        });

when we use id s for qtip every thing is so simple and we can find target s content easily!
but in my scenario i have many id s that i do n t know how can i recognize their content by the upper code !

i mean :

        $( .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 
        });

thanks in advance

最佳回答

Way 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 
            });

way 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);
    });
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签