JQuery Toggle property contentEditable = "true"
javascript, jquery
Solution
Try this way:
$( "#mylabel" ).click(function() {
var value = $('#editablediv').attr('contenteditable');
if (value == 'false') {
$('#editablediv').attr('contenteditable','true');
}
else {
$('#editablediv').attr('contenteditable','false');
}
});
Keep me posted, hope this helped
Problem
I am using contenteditable="true" in a div What I want to do it to toggle true and false on this attribute everytime I click on a div. example: ``` $( "#mylabel" ).click(function() { $('#editablediv').attr('contenteditable','false'); }); ``` I tried: ``` $( "#mylabel" ).toggle(function() { $('#editablediv').attr('contenteditable','false'); }); ``` but that didn't work How can I do this?