开发者

Jquery, Ajax tooltip help

开发者 https://www.devze.com 2023-04-08 05:18 出处:网络
im using a Jquery + Ajax tooltip which displays a box displaying the context thru AJAX, but the title of the tooltip box is set to be \"kbay.in\" and the text in the \"a\" tag,, now how do i change it

im using a Jquery + Ajax tooltip which displays a box displaying the context thru AJAX, but the title of the tooltip box is set to be "kbay.in" and the text in the "a" tag ,, now how do i change it to display the title as the value, id, name ,or anythin else of the "a" tag , than the text in it:

    $(this).qtip(
    {
        content: {
            // Set the text to an image HTML string with the correct src URL to the loading image you want to use
            text: '<img class="throbber" src="http://www.craigsworks.com/projects/qtip/images/throbber.gif" alt="Loading..." />',
            ajax: {
                url: $(this).attr('rel') // Use the rel attribute of each element for the url to load
            },
            title: {
                text: 'Kbay.in' + $(this).name(), // Give the tooltip a title using each elements text
                button开发者_C百科: true
            }
        },


Like this?

title: {
    text: $(this).prop('value'); // this is the 'value'.. for example
}


I THINK that you are looking for $(this).attr("name");

or $(this).attr("id");

etc etc


Firstly, make sure $(this) is actually your "a" element so that you know you're grabbing the correct value. Once you know that for sure, the following code should help you:

<a id="mylink" class="foo" href="blah.html">Testing link text</a>

var _link = $(this);   // Helps keep track of $(this)

_link.qtip(
    {
        ...
        title: {
            text: 'Kbay.in ' + _link.text(),             // Kbay.in Testing link text
            // text: 'Kbay.in ' + _link.attr('id'),      // Kbay.in mylink
            // text: 'Kbay.in ' + _link.attr('href'),    // Kbay.in blah.html
            // text: 'Kbay.in ' + _link.attr('class'),   // Kbay.in foo
            button: true
        }
    }

$.text() and $.value() grab whatever is between your link's open and close tags without HTML as opposed to the $.html() method which returns the markup:

// $(this).text() = "Testing link text"
// $(this).html() = "Testing link text"
<a href="blah.html">Testing link text</a>             

// $(this).text() = "Testing link text"
// $(this).html() = "Testing <b>link</b> text"
<a href="blah.html">Testing <b>link</b> text</a>  
0

精彩评论

暂无评论...
验证码 换一张
取 消