Javascript content仅可用于某些类 [英] Javascript contentEditable of certain classes only
本文介绍了Javascript content仅可用于某些类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下脚本可编辑HTML页面
I have the following script that makes an HTML page editable
document.body.contentEditable = 'true'; document.designMode='on';
我只希望我的用户使用"edit"类来编辑部分.这可能吗?
I am wanting to only allow my users to edit sections with a class of "edit". Is this possible?
推荐答案
您可以尝试找到所有类名为"edit"的元素,然后像下面那样将其全部更改.
YOu can try to find all the elements with the class name 'edit' and change all off them like below.
document.querySelectorAll('.edit').forEach(function(element){
element.contentEditable = 'true';
})
这篇关于Javascript content仅可用于某些类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文