HTML5内容可以使用jQuery进行编辑 [英] HTML5 contentEditable with jQuery

查看:114
本文介绍了HTML5内容可以使用jQuery进行编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些需要将文本内部编辑的元素,为此,我使用HTML 5属性contentEditable。我似乎无法使用jQuery为此使用多个选择器。我想要做的是让容器div中的每个标签都是可编辑的。这里有一个例子,说明如果它使用jQuery它会是什么样子的:

  $(#container< here tags here> ).contentEditable =true; 

我不知道如何让它选择所有标签,但是您明白了。

所以所有span,div,表格,粗体等都应该可以单独编辑

解决方案 div>

  $('#container *')。attr('contenteditable','true'); 

* 表示所有元素类型,并类似于 a,div,span,ul等...



像大多数其他jQuery函数一样, attr 对选择器捕获的每个元素应用相同的操作。 p>

I have some elements that need to have the text inside editable, for this I am using the HTML 5 attribute contentEditable. I can't seem to do use jQuery for this using multiple selectors. What I want to do is have every tag inside a container div be editable. Here's an example of what it would look like if it worked with jQuery:

$("#container <all tags here>").contentEditable = "true";

I dont know how to make it select all tags but you get the point.

So all span, div, tables, bold, etc should be editable individually

解决方案

$('#container *').attr('contenteditable','true');

* means "all element types", and is analogous to a,div,span,ul,etc...

Like most other jQuery functions, attr applies the same operation to every element captured by the selector.

这篇关于HTML5内容可以使用jQuery进行编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆