Sunday, May 12, 2024
 Popular · Latest · Hot · Upcoming
33
rated 0 times [  36] [ 3]  / answers: 1 / hits: 18749  / 10 Years ago, sat, april 19, 2014, 12:00:00

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?


More From » jquery

 Answers
7

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


[#71389] Thursday, April 17, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
xochitl

Total Points: 559
Total Questions: 95
Total Answers: 117

Location: Antigua and Barbuda
Member since Sat, Apr 24, 2021
3 Years ago
;