开发者

How to open editor in click

开发者 https://www.devze.com 2022-12-09 18:45 出处:网络
I have page with 5 divs and i want to open editor on click of selected di开发者_如何学Pythonv .

I have page with 5 divs and i want to open editor on click of selected di开发者_如何学Pythonv .

And div content will come into the editor what i will do for this.

is there any j query for this.


Do you want to edit the contents in place? Have you looked at the Jeditable plugin?


Check out NicEdit or TinyMCE. Both can be configured to edit the content in a div or any other element.


    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

精彩评论

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

关注公众号