onkeyup, onkeydown events not firing for SPAN element

后端 未结 3 2014
陌清茗
陌清茗 2020-12-20 05:11

I\'ve defined the following two span elements: 1) element inside a contenteditable div. 2) contenteditable element.

So far, I can\'t get the onkey events to fire

3条回答
  •  无人及你
    2020-12-20 06:01

    Because the span1 is not a contenteditable so it will not fire any event.

    You can set contenteditable on child too, but it will not fired because the wrapping contenteditable div editor catch the events before the inner span, so they are not fired on the child span1.

    So you can change your code in:

    div contents... Hello
    World

    Demo: http://jsfiddle.net/IrvinDominin/U8wnK/

    Side note: I think it's better to explicit the boolean value of contenteditable in your markup

提交回复
热议问题