代码之家  ›  专栏  ›  技术社区  ›  Attila O.

TinyMCE提示文本

  •  3
  • Attila O.  · 技术社区  · 14 年前

    Remy Sharp's jQuery plugin 在文本框中显示提示。

    我也要这样做 TinyMCE "Type some text here." ,当用户聚焦TinyMCE编辑器时,该文本应该消失。如果编辑器为空(未输入文本),则在“模糊”时,文本应再次可见。

    有没有jQuery插件可以做到这一点?或者TinyMCE中是否有一个API可用于此功能?

    1 回复  |  直到 14 年前
        1
  •  4
  •   JKirchartz    14 年前

    <textarea name="content" id="content">Type some text here</textarea>
    

    应该显示该文本,然后使用jQuery您应该能够执行以下操作:

    TinyMCE.focus(function(){
     if ($(this).getContent() == "Type some text here"){
      tinyMCE.setContent("");
     } else if ($(this).getContent() == ""){
      tinyMCE.setContent("Type some text here");
     }
    })