vendredi 26 décembre 2014

HTML 5 toggling the contenteditable attribute with javascript

enter code hereI am trying to make something editable online with a function like this



function toggle_editable (div, cssclass) {

var classToEdit = document.getElementsByClassName(cssclass)

for (i = 0;classToEdit.length; i++) {

if (classToEdit[i].contentEditable == false) {
classToEdit[i].contentEditable = true ;
}
if (classToEdit[i].contentEditable == true) {
classToEdit[i].contentEditable = false ;
}
}
}


neither of the if statements work


this works however


classToEdit.contenteditable = true; as well as this



classToEdit.contenteditable = false;


but this isn't


if (classToEdit.contenteditable == true) /or false


ideas anyone?


Aucun commentaire:

Enregistrer un commentaire