我正在使用JQUERY和JQUERY UI来更改一个小文本字符串的标题值。当页面首次加载时,工具提示正常工作,并显示我的“单击展开”工具提示。当用户单击“more…”或“less…”文本时,它应该触发点击功能(它确实这样做);切换博客文章的可见性(它确实这样做);将更多的文本切换为更少或反之亦然(它确实这样做);然后更新按钮的标题,以便工具提示显示新文本(如Chrome中所见,它确实更新)。但是,工具提示从未更改,即使标题说“折叠文章”,工具提示仍然显示“单击以获取更多信息”。
如何动态更新我的标题,以便JQUERY UI工具提示看到更新并在鼠标悬停时正确报告新值?
如何动态更新我的标题,以便JQUERY UI工具提示看到更新并在鼠标悬停时正确报告新值?
/*
*
* @DocumentReady
*/
$(window).ready(function(){ //Checks if the document is ready
/*
*
*
*/
$(".moreButtonClass").click(function(){ //Handles the button click
// just leaves the number and appends to make the div ID
var postID = "#post" + this.id.replace(/[^\d]/g, "");
var moreButton = "#moreButton" + this.id.replace(/[^\d]/g, "");
$(postID).toggle(); // Toggle visibility
if($(postID).is(":visible")) {
$(moreButton).text("less...");
$(moreButton).attr("title", "Collapse Post");
} else {
$(moreButton).text("more...");
$(moreButton).attr("title", "Show Post");
}
}); //Close the function
/*
*
*
*/
$( "#tabs" ).tabs({
beforeLoad: function( event, ui ) {
ui.jqXHR.error(function() {
ui.panel.html(
"Couldn't load this tab. We'll try to fix this as soon as possible. ");
});
}
}); // Close the function
/*
*
*/
$(function() {
$( document ).tooltip({track: true}); // Allow JQUERY to handle tooltips
}); // Close the function
}); // Close the Document Ready Function