Jquery,Ajax工具提示帮助
即时消息使用Jquery+Ajax工具提示,该工具提示显示一个通过Ajax显示上下文的框,但工具提示框的标题设置为“kbay.in”和“a”标记中的文本,现在我如何更改它以显示标题作为“a”标记的值、id、名称或任何其他内容,而不是其中的文本:Jquery,Ajax工具提示帮助,ajax,jquery-ui,jquery,Ajax,Jquery Ui,Jquery,即时消息使用Jquery+Ajax工具提示,该工具提示显示一个通过Ajax显示上下文的框,但工具提示框的标题设置为“kbay.in”和“a”标记中的文本,现在我如何更改它以显示标题作为“a”标记的值、id、名称或任何其他内容,而不是其中的文本: $(this).qtip( { content: { // Set the text to an image HTML string with the correct src URL to the
$(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: true
}
},
$(this).qtip(
{
内容:{
//将文本设置为图像HTML字符串,并将正确的src URL设置为要使用的加载图像
文本:“”,
阿贾克斯:{
url:$(this).attr('rel')//使用每个元素的rel属性来加载url
},
标题:{
text:'Kbay.in'+$(this).name(),//使用每个文本元素为工具提示提供标题
按钮:正确
}
},
像这样吗
title: {
text: $(this).prop('value'); // this is the 'value'.. for example
}
我想您正在寻找
$(this).attr(“name”);
或$(this.attr(“id”);
etc etc首先,确保$(this)实际上是您的“a”元素,这样您就知道您正在获取正确的值。一旦您确定了这一点,下面的代码应该可以帮助您:
<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
}
}
var _link=$(this);//帮助跟踪$(this)
_link.qtip(
{
...
标题:{
text:'Kbay.in'+\u link.text(),//Kbay.in测试链接文本
//文本:'Kbay.in'+\u link.attr('id'),//Kbay.in mylink
//文本:“Kbay.in'+_link.attr('href'),//Kbay.in blah.html
//文本:“Kbay.in'+\u link.attr('class'),//Kbay.in foo
按钮:正确
}
}
$.text()和$.value()获取链接的打开和关闭标记之间的任何内容,而不使用HTML,与返回标记的$.HTML()方法相反:
// $(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>
/$(this).text()=“测试链接文本”
//$(this).html()=“测试链接文本”
//$(this).text()=“测试链接文本”
//$(this).html()=“测试链接文本”
实际上不是,请使用attr。阅读实际文档。与您希望访问DOM属性的文档不同。在这种情况下,jQuery会屏蔽您的真实性。让我们尝试让您更清楚地了解这一点……使用属性的唯一原因是,如果DOM元素将被动态操作,如复选框“选中”或者类似的东西。在这种情况下,默认属性保持不变。从功能上来说,因为它们在这种情况下工作相同,所以我不会告诉你使用prop是错误的,但是你试图纠正我只使用prop是错误的。