为什么qtip2插件不是't使用HTML
Why qtip2 plugin isn't working with HTML?
我正在尝试用qtip2做一个html工具提示。但是,按照网站上的简单例子,我只是调整了一下我的课程。但是,我不知道为什么这不起作用。如果我将.formreprovar'
更改为.tooltiptext
,它将正常工作。感谢
JSFIDDLE
JS
$(document).ready(function()
{
$('.reprovar').qtip({
position: {
my: 'bottom center',
at: 'top center'
},
style: {
classes: 'qtip-light'
},
content: {
button: 'close',
text: $(this).nextAll('.formreprovar').first()
},
hide: {
fixed: true,
event: false
},
show: {
event: 'click'
}
});
});
HTML
<input type="button" value="Reprovar" class="btn btn-danger reprovar">
<div class="formreprovar">
<input type="text" />
<b>oiiiiiiiiiiii</b>
</div>
CSS
body {
padding: 50px;
}
.tooltiptext {
display: none;
}
.formreprovar {
display: none;
}
试试这个
$(this).nextAll('.formreprovar').first().text()
next
获取选择器的紧随其后的同级。如果没有找到,那么它只是一个empty jQuery object
.next('.tootiptext')
是直接同级,而.formreprovar不是
也不要忘记选择器后面的.text()
部分。
检查Fiddle
更新
问题似乎出在text
方法内的this
上下文上。
将其封装在函数中,以便上下文指向有问题的元素。
content: {
button: 'close',
text: function() {
return $(this).nextAll('.formreprovar').first()
}
},
工作Fiddle
相关文章:
- 使用html中的外部javascript进行数据验证
- 这是使用html快照和谷歌获取的预期结果吗?SEO/SPA
- 使用html表单中的参数调用JavaScript函数
- 有没有一种方法可以仅使用HTML/CSS来隐藏基于特定值的数据单元格
- 在Angular中重新使用HTML端的计算文本
- 当#在iFrame中使用HTML时,阻止页面移动
- 回复'js'仅当请求有错误时(否则使用html)
- 具体化:如何只使用HTML和Javascript制作播放/暂停按钮
- http请求使用html而不是json进行响应
- 使用HTML进行Visual Basic UI设计
- 使用html和Javascript进行客户端排序
- 如何在angularJS中运行for循环而不使用html标记
- 在javascript函数中使用@Html.Raw
- 如何使用HTML/CSS/JavaScript开发桌面应用程序
- 如何使用HTML、CSS和JavaScript创建自动图片库幻灯片
- 在JavaScript中使用HTML变量
- 对javascript使用.html中的select id
- 使用HTML和JS的iPhone游戏中的性能问题,以及appMobi
- 使用HTML标记中的JS变量在Javascript中动态创建HTML
- 允许在Angular控制器或视图中使用html标记