admin管理员组

文章数量:1331849

I am trying to change the hyperlink title using javascript/jquery when the link is clicked. HTML

<a 
        href="javascript:addRss('234');" 
        class="btn btn-success" 
        title="Add content to Personal RSS" 
        id="addRssbtn" 
        data-toggle="tooltip" >
            <i class="fa fa-rss fa-lg"></i> 
        </a>

CSS

@import url(".1.1/cerulean/bootstrap.min.css");
@import url(".1.1/css/bootstrap-theme.min.css");
@import url(".0.3/css/font-awesome.min.css");

JAVASCRIPT

$(function (){$('[data-toggle="tooltip"]').tooltip({});});


function addRss(hash){
        $("#addRssbtn").attr("class", "btn btn-success active");
        $("#addRssbtn").attr("title", "Remove content from Personal RSS");
        $("#addRssbtn").attr("href", "javascript:unaddRss(" + hash + ");");

//some other post data stuff
};

the title gets changed and shows too, only if i am not using

data-toggle="tooltip"

so how can i make the data-toggle="tooltip" to show the new changed title as a tooltip when the link is clicked ?

/

above code is working except the new tooltip on my pc but not on jsfiddle.

I am trying to change the hyperlink title using javascript/jquery when the link is clicked. HTML

<a 
        href="javascript:addRss('234');" 
        class="btn btn-success" 
        title="Add content to Personal RSS" 
        id="addRssbtn" 
        data-toggle="tooltip" >
            <i class="fa fa-rss fa-lg"></i> 
        </a>

CSS

@import url("http://netdna.bootstrapcdn./bootswatch/3.1.1/cerulean/bootstrap.min.css");
@import url("http://netdna.bootstrapcdn./bootstrap/3.1.1/css/bootstrap-theme.min.css");
@import url("http://netdna.bootstrapcdn./font-awesome/4.0.3/css/font-awesome.min.css");

JAVASCRIPT

$(function (){$('[data-toggle="tooltip"]').tooltip({});});


function addRss(hash){
        $("#addRssbtn").attr("class", "btn btn-success active");
        $("#addRssbtn").attr("title", "Remove content from Personal RSS");
        $("#addRssbtn").attr("href", "javascript:unaddRss(" + hash + ");");

//some other post data stuff
};

the title gets changed and shows too, only if i am not using

data-toggle="tooltip"

so how can i make the data-toggle="tooltip" to show the new changed title as a tooltip when the link is clicked ?

http://jsfiddle/h5kKa/

above code is working except the new tooltip on my pc but not on jsfiddle.

Share Improve this question asked Apr 29, 2014 at 13:05 user1642018user1642018
Add a ment  | 

2 Answers 2

Reset to default 8

Update the tooltip using the fixTitle option.

$("#addRssbtn").attr("title", "Remove content from Personal RSS")

Bees

$("#addRssbtn").attr("title", "Remove content from Personal RSS").tooltip('fixTitle');

You can add .tooltip('show'); to show the tooltip straight after:

$("#addRssbtn").attr("title", "Remove content from Personal RSS").tooltip('fixTitle').tooltip('show');

http://jsfiddle/h5kKa/2/

You weren't looking for anything like this this were you?

$("#addRssbtn").tooltip("option", "content", "title");

Here is a jfiddle for it

E: just beaten

本文标签: Bootstrap 3How to change the hyperlink title text showing as tooltip using javascriptjqueryStack Overflow