2015-07-20 37 views
-1

我试图通过jQuery来显示文本内容文本

$(function() { 
    $(".outer").tooltip({ 
     content: "Awesome title!", 
     position: { my: "left+15 center", at: "right center" }, 
     content: function() { 
      return $(this).prop('title'); 
     } 
    }); 
}); 

HTML

<p class="outer"> 
    <label for="age">Your age:</label> 
    <input id="age" 
    title="<label id='idhere'></label>"/> 
</p> 

JSFIDDLE

如何显示 “真棒称号!”当鼠标悬停在jquery上?

+1

你有2个内容。只需删除第二个:https://jsfiddle.net/Lqsb6adp/11/ –

+0

是的,但使用第二个内容:https://jsfiddle.net/Lqsb6adp/12/ –

回答

0

我已经更新您的小提琴手:

https://jsfiddle.net/Lqsb6adp/2/

$(function() { 
    $(".outer").tooltip({ 
     content: "Awesome title!", 
     position: { my: "left+15 center", at: "right center" }, 
    }); 
}); 
0

只需设置title属性与你所需要的不是content

JsFiddle

两次覆盖内容:

首播时间:

content: "Awesome title!", 

二时间:

content: function() { 
      return $(this).prop('title'); 
     } 

只需使用第二次设置标题属性作为小提琴链接。或者你可以在没有标题属性的情况下首次使用,但是只有其中一个不是两个。

0

由于您使用的是.outerproperty title,你需要指定title="Awesome title!"div.outer。所以更新的HTML变为:

<p class="outer" title="Awesome title!"> 
    <label for="age">Your age:</label> 
    <input id="age" 
    /> 

</p> 

见琴: “http://jsfiddle.net/Lqsb6adp/6/