开发者

Client, editing dynamically the value of the dom elements such as <div><p>Javascript

Are there relatively simple ways to implement 开发者_Python百科this:

  • I have a div element with position absolute
  • I am doing double click on it
  • Now focus is on this div, there is a caret appeared
  • I am typing and value of this div is changing

Thanks!


You should check out content editable. Here's an example: http://jsfiddle.net/Jk5zn/. And if you are worried about browser coverage, do not worry: http://caniuse.com/#search=contented


For the case that you don't want to use jquery (or other frameworks for this)...

You almost written the algorithm by yourself!

When ondblclick event of the div fires, show pre-created textarea on the position of the div. When onblur event of that texarea fires, just pass the value of textarea to innerHTML of the div.

thats the magic.


This calls inline editing, a simple search returned this blog entry

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜