Make span element “editable”

前端 未结 5 489
逝去的感伤
逝去的感伤 2021-01-01 14:47

I have a span element that I want to become editable upon double-click. (That is, the user can edit the text and it will save when s/he clicks outside.)

5条回答
  •  借酒劲吻你
    2021-01-01 15:19

    The above works: I've tested it in this jsfiddle: http://jsfiddle.net/nXXkw/

    Also, to remove the editability when user clicks off of the element, include:

    $('span').bind('blur',function(){
        $(this).attr('contentEditable',false);
    });
    

提交回复
热议问题