also in etwa so:
Javascript:
$(document).ready(function() {
restoreContents();
$('#edit').bind('click', toggleEditContent);
$('#clear').bind('click', resetContent);
function saveContents() {
var rbIsClicked = $('#rbIsClicked').html();
localStorage['rbIsClicked'] = rbIsClicked;
}
function restoreContents() {
var myrbIsClicked = localStorage['rbIsClicked'];
if (myrbIsClicked != undefined) {
$('#rbIsClicked').html(myrbIsClicked);
}
}
function toggleEditContent(e) {
if ($('#rbIsClicked').attr('contenteditable') == 'false') {
$('#rbIsClicked').attr('contenteditable', 'true');
$('#edit').val('Speichern');
$('#rbIsClicked').focus();
} else {
$('#rbIsClicked').attr('contenteditable', 'false');
$('#edit').val('Bearbeiten');
saveContents();
}
}
function resetContent(e) {
localStorage.clear();
window.location.reload();
}
});
Zuletzt bearbeitet: