当另一段代码在其上调用a
时,我需要从.text('string')
元素中删除一个类。我无法编辑其他代码:
function WPSetAsThumbnail(id, nonce){
var $link = jQuery('a#wp-post-thumbnail-' + id);
// this is where it's first called
$link.text( setPostThumbnailL10n.saving );
jQuery.post(ajaxurl, {
action:"set-post-thumbnail", post_id: post_id, thumbnail_id: id, _ajax_nonce: nonce, cookie: encodeURIComponent(document.cookie)
}, function(str){
var win = window.dialogArguments || opener || parent || top;
$link.text( setPostThumbnailL10n.setThumbnail );
if ( str == '0' ) {
alert( setPostThumbnailL10n.error );
} else {
jQuery('a.wp-post-thumbnail').show();
$link.text( setPostThumbnailL10n.done );
$link.fadeOut( 2000 );
win.WPSetThumbnailID(id);
win.WPSetThumbnailHTML(str);
}
}
);
}
非常感谢你对我的支持,即使这是一个非常棒的问题。
答案 0 :(得分:1)
两个选项:
第二个选项示例:
var $element = $("#elementId");
var lastText = $element.text();
function checkForChanges()
{
var currText = $element.text();
if (currText !== lastText)
{
alert('xxx');
lastText = currText;
}
}
var id = setInterval(checkForChanges, 500);