2009-10-27 110 views

回答

1

你想现场编辑的内容?你看过Jeditable插件吗?

+0

谢谢伟大的答案,但我也需要一个编辑器。 如果我点击那么它将进入编辑模式与文本编辑器。 – 2009-10-27 14:33:32

+0

然后我会用Matthew的建议! :) – Mottie 2009-10-27 14:46:09

1

查看NicEdit或TinyMCE。两者都可以配置为编辑div或其他任何元素中的内容。

0
CSS: 
    .hidden{ 
     display:none; 
    } 

    <div id="container"> 
     <div id="div1" class="edit-div"><div class="editor hidden"></div><div class="content"></div></div> 
     <div id="div2" class="edit-div"><div class="editor hidden"></div><div class="content"></div></div> 
     <div id="div3" class="edit-div"><div class="editor hidden"></div><div class="content"></div></div> 
     <div id="div4" class="edit-div"><div class="editor hidden"></div><div class="content"></div></div> 
     <div id="div5" class="edit-div"><div class="editor hidden"></div><div class="content"></div></div> 
    </div> 

var xeditorChange = function(el) 
{ 
    if ($(el).length>0) 
    { 
    $(el).find(".content") 
      .empty() 
      .html(editor.getText()) 
      .removeClass("hidden"); 

    $(el).find(".editor") 
     .empty() 
     .addClass("hidden"); 
    } 
}; 

$(function(){ 
    $(".edit-div").click(function() 
{ 
    xeditorChange($("#container").find(".editing")); 

    editor.addText($(this).find(".content").html()); 
    $(this).find(".content").addClass("hidden"); 
    $(this).find(".editor").removeClass("hidden"); 

    //show editor in $(this).find(".editor") 
}); 

    //on save text in editor add the html with reverse function 

}); 
+0

感谢您的回复,但它不适合我。 你有任何其他的方式来做到这一点。 – 2009-10-27 14:39:13

+0

我不知道你有什么编辑器,但据我探查剧本的作品。你将不得不适应编辑器,你使用函数editor.getText()和editor.addText(...) – 2009-10-27 15:55:09

相关问题