0

I have the following HTML5 content:

<section contenteditable="true" id="editable" class="ui-selectee ui-selected">
<span>something</span>
<span>something</span>
<span>something</span>
</selection>

I have a toggle function that turns on edit mode. I want to make the contenteditable="true" or contenteditable="false" on that toggle function. I've it would be easy if I would have to change a class or ID. Ive tryed to .html the #edit or append but I was unable to.

Any tips on changing contenteditable="true" to contenteditable="false" ? Thanx

2 Answers 2

3

You are going to want to use the attr() function.

To set the value to true:

attr("contenteditable", "true");
Sign up to request clarification or add additional context in comments.

Comments

1

....

$('selector').click(function(){
  $('#editable').attr('contenteditable', false);
});

You can use the if-else condition to check its current status and set the required on accordingly using:

$('#editable').attr('contenteditable', false); // or true

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.