gpt4 book ai didi

javascript - jQuery UI 工具提示 - 动态内容

转载 作者:行者123 更新时间:2023-11-28 01:28:13 25 4
gpt4 key购买 nike

我想在拖动具有工具提示的 div 时更改工具提示的内容。我想使用 div 的拖动事件在工具提示中显示 ui.position.top 。这可能吗?我知道jQuery UI API docs关于工具提示内容说:

When changing this option, you likely need to also change the items option.

但我不知道如何正确地做到这一点。

这就是我所拥有的:

HTML

<div id="box" title="original">drag me</div>

JS

$("#box").tooltip({
track: true
});
$("#box").draggable({
drag: function(event,ui){
$(this).tooltip("option", "content", ui.position.top);
}
});

http://jsfiddle.net/E9vf3/8/

最佳答案

detailed in the API初始化后,您可以获取或设置 content 选项。您对问题的最新修改几乎是正确的,但工具提示期望一个字符串作为最终值。

$("#box").tooltip({
track: true
});
$("#box").draggable({
drag: function(event,ui){
$(this).tooltip( "option", "content", ""+ui.position.top );
}
});

http://jsfiddle.net/E9vf3/10/

关于javascript - jQuery UI 工具提示 - 动态内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22453126/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com