私のページには、タイトル属性を使用する他の jquery プラグインがあるため、jquery ツールチップが「タイトル」以外の属性からデータを取得することは可能ですか? http://flowplayer.org/tools/tooltip/index.html#configuration
<span class="something" title="This is title" otherattr="This is the tooltips"></span>
私のページには、タイトル属性を使用する他の jquery プラグインがあるため、jquery ツールチップが「タイトル」以外の属性からデータを取得することは可能ですか? http://flowplayer.org/tools/tooltip/index.html#configuration
<span class="something" title="This is title" otherattr="This is the tooltips"></span>
jTools Tooltip のドキュメントを正しく理解していれば、$("[title]") 以外のセレクターでツールチップを設定すると、トリガーの直後の要素がツールチップ コンテンツとして使用されます。
したがって、次のようなことができます。
$(document).ready(function(){
//place a span with class tooltip after each element with otherattr attribute placing the otherattr text inside it
$("[otherattr]").each(function(){
$(this).after('<span class="tooltip">' + $(this).attr("otherattr") + '</span>');
});
//when we initate the tooltip this way it will use the .tooltip span after each element.
$("[otherAttr]").tooltip();
});
ツールチップのコンテンツとして関数を指定し、プログラムで属性からコンテンツを取得できます。この場合、属性「otherattr」が必要なので、次のことを試すことができます。
$(".something").tooltip({
"content": function(){
return $(this).attr("otherattr");
}
});
これを理解するためにいくつかのソースコードを掘り下げる必要がありました。デフォルトでは、ツールチップの「コンテンツ」は次のようにして見つけることができます
$(".something").tooltip("option", "content")
そしてそれが返されることを確認してください:
function (){var e=t(this).attr("title")||"";return t("<a>").text(e).html()}
したがって、デフォルトの関数を使用する代わりに、独自の関数を作成してください。それが役立つことを願っています!