user3792705
user3792705

Reputation: 617

How to remove 'contenteditable' attribute when saving html in JQuery

$mydiv's child elements are editable. I want to save html into db and expect small html. The following property removal not work.

How to make it work?

let big_html = $mydiv.html();

$mydiv.children().each(function () {
  $(this).removeProp('contenteditable');   // Not work!
});

let small_html = $mydiv.html();

Upvotes: 2

Views: 373

Answers (1)

Vickel
Vickel

Reputation: 7997

contenteditable is a global attribute not a property

you can manipulate it

$(this).attr('contenteditable',true) // or false

or remove it:

$(this).removeAttr('contenteditable')

Upvotes: 3

Related Questions