Question

I want to simply display a parameter value from a jQuery tooltip function here is my code for it

that.SampleToolTip = function (iOaCount, iObCount,iTotalCount) {
    $("#assignment").hover(function () {
        if (iTotalCount != 0) {
            var count = 0;
            $("#assignment").attr('title' + iOaCount+'This is the hover-over text');

        }
    });          
}

Here, if I simply display line 'title' then it is displayed in tooltip but not the function parameters. When I display function parameter then tooltip is not displayed. I tried this also:

var count=icount;

and then displaying count in tooltip but it didn't work.

Was it helpful?

Solution

you are not setting the title attribute but getting a value of attribute with name: 'title' + iOaCount+'This is the hover-over text'

you are missing a comma. change you code to:

  $("#assignment").attr('title', iOaCount + 'This is the hover-over text');

if the function is used with one parameter then it retrieves the attribute value. if with two parameters than it sets the value of the attribute with the second parameter.

You can see that in jquery documenation: jquery attr

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top