我有以下 jquery,当您单击链接时,它只会更新其上的文本和类。它在 Chrome 中运行良好,但在 IE 中,您必须单击链接两次才能执行任何操作。我会理解它是否根本不起作用,但无法弄清楚为什么您需要单击它两次!
// Subscribe to topic subscribedtotopic
$(".notsubscribedtotopic")
.on("click", (function () {
SubscribeUnsubscribe($(this));
}));
// UnSubscribe to topic subscribedtotopic
$(".subscribedtotopic").on("click", (function () {
SubscribeUnsubscribe($(this));
}));
function SubscribeUnsubscribe(link) {
var topicid = link.attr('rel');
link.slideUp('fast');
if (link.attr('class') == 'notsubscribedtotopic') {
link.html('Unsubscribe From Topic');
link.removeClass('notsubscribedtotopic').addClass('subscribedtotopic');
link.slideDown();
return false;
} else {
link.html('Subscribe To Topic');
link.removeClass('subscribedtotopic').addClass('notsubscribedtotopic');
link.slideDown();
return false;
}
};