我無法切換屬性contenteditable
。默認情況下,我在HTML代碼中將其硬編碼爲false
,當我單擊#edit-button
時,它將變爲false
。但是當我再次點擊它時,沒有任何反應。看起來else
-從未被觸發。jQuery不會切換contenteditable點擊和/ href不禁用
我也試圖禁用每個a/button href
但我在這個問題上也沒有成功。下面的if語句是錯誤的嗎?
if ($(this).is(':button')) {
$(this).attr('href', '#');
}
的jQuery:
$('#edit-button').on('click', function() {
$('section').each(function() {
$(this).find('[contenteditable]').each(function() {
if ($(this).attr('contenteditable', false)) {
$(this).attr('contenteditable', true);
$('#header').focus();
if ($(this).is(':button')) {
$(this).attr('href', '#');
}
} else {
$(this).attr('contenteditable', false);
}
});
});
});
試圖通過左右,但和谷歌沒有運氣搜索。
感謝您的幫助。
您需要添加屬性或removeAttr作爲CONTENTEDITABLE,不要使用CONTENTEDITABLE或真或假。 –