user3770114
user3770114

Reputation:

Send tooltip title text dynamically

I use text which is hardcoded in the title section, the problem is I need to use it in diffrent label with diffrent text title and not hardcoded to all the labels ,how should I change it to support any label with diffrent titile text.

<div class="form-group">
            @Html.LabelFor(model => model.User, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.User)
                <span class="label label-primary tooltip">?</span>
            </div>

    </div>

JS

 function () {    
            $(".tooltip").tooltip({
                animation: "true",
                placement: "right",
                title: "My text",
                trigger: "hover"
            });

Upvotes: 2

Views: 322

Answers (1)

Shimi Tal
Shimi Tal

Reputation: 627

Im not sure if this is the right forum :) (I guess its related to JS),but anyhow you can do it like following:

1.add title with the text

2.use this code:

$("[title]").tooltip({
    animation: "true",
    placement: "right",
    trigger: "hover"
});

In this case you take the text from the title.

Good luck!

Upvotes: 1

Related Questions