jQuery event for html change in a div element?

前端 未结 5 2148
抹茶落季
抹茶落季 2021-02-14 16:48

Long story short - I have an editable

and I want to clear formatting when someone pastes something in. Since jQuery has no control over the clipboard an
5条回答
  •  礼貌的吻别
    2021-02-14 17:26

    You can use a 'keydown' event - it will capture shift key presses so works for pasting, as well as the delete key.

    If you need to detect whether the content has changed, store the old content and compare when the event is fired.

    To capture paste by mouse, you'll probably need to compare current content to old content periodically based on a timer. You could reduce some overhead by activating the timer on focus, and stopping it on blur.

提交回复
热议问题