Javascript 获取没有ID(和qtip)的标记的innerHTML
我需要使用Javascript 获取没有ID(和qtip)的标记的innerHTML,javascript,html,qtip,Javascript,Html,Qtip,我需要使用class=“tip”(例如“此处的某个数字”)使qtip工具提示文本等于每个标记的值。最好不使用ID <a class="tip">some number here</a> <script type="text/javascript"> $('.tip').each(function() { $(this).qtip({ content: { text: "tooltip here"
class=“tip”
(例如“此处的某个数字”)使qtip工具提示文本等于每个标记的值。最好不使用ID
<a class="tip">some number here</a>
<script type="text/javascript">
$('.tip').each(function() {
$(this).qtip({
content: {
text: "tooltip here"
}
})
})
</script>
这里有一些数字
$('.tip')。每个(函数(){
$(此).qtip({
内容:{
文本:“此处的工具提示”
}
})
})
要访问触发QTip的元素的属性,必须以以下方式构造代码:
$("#container a").each(function() {
$(this).qtip({ // QTip code });
});
这样,就可以使用$(this)访问触发QTip的元素的innerHTML等数据
这里有一个工作代码:这里有一些数字
$('.tip')。每个(函数(){
var tipNumber=$(this.text();
$(此).qtip({
内容:{
文本:tipNumber;
}
})
})
所以我只是缺少$(this).text.后面的括号。。谢谢你,伙计。
<a class="tip">some number here</a>
<script type="text/javascript">
$('.tip').each(function() {
var tipNumber = $(this).text();
$(this).qtip({
content: {
text: tipNumber;
}
})
})
</script>